Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Populating Hidden Field Value with Value Entered in CMS

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2146 Views
  • geisha64
    Community Member
    5 Posts

    Populating Hidden Field Value with Value Entered in CMS Link to this post

    I have created a custom field called retURL for the user to enter a URL in the CMS. I want to access this value in the Custom form hidden field.

    I have tried the following and get the value "Array" back:
    new HiddenField("retURL","retURL",DataObject::get('RegistrationForm')->column('retURL')),

    Can someone point me in the right direction on how to access the retURL value for the specific page that is created off of this RegistrationForm page type?

    class RegistrationForm extends Page {

    static $db = array(
    'retURL' => 'Varchar(255)'

    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Content.Main', new TextField('retURL','Page URL'), 'Content');
    return $fields;

    } //class RegistrationForm

    class extForm extends Form {
    function init() {

    class RegistrationForm_Controller extends Page_Controller {

       function Form() {
          return new extForm($this, "Form", new FieldSet(

             // List your fields here
             new TextField("first_name", "First Name"),
             new TextField("last_name","Last Name"),
             new HiddenField("retURL","retURL",DataObject::get('RegistrationForm')->column('retURL')),

          ), new FieldSet(

             // List the action buttons here
             new FormAction("", "Sign up")

          ), new RequiredFields(

             // List the required fields here: "Email", "FirstName"


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.