Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Can't insert dynamic value into HiddenField

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

Page: 1
Go to End
Author Topic: 409 Views
  • _Matt
    Community Member
    25 Posts

    Can't insert dynamic value into HiddenField Link to this post

    I'm trying to automatically insert a dynamic value into a HiddenField, but I can't get it working. At the moment I just get 'value="0"'.

    This is a simplified version of what I'm trying to do:

    static $db = array(
    'MyID' => 'Int'

    public function getCMSFields()
    $fields = parent::getCMSFields();

    $myID = 9999; // In my code this value is set dynamically

    return new FieldList(
    new HiddenField('MyID', 'My ID', $myID)

    My dynamic value definitely works as I'm able to var_dump() it.

    Can anyone explain why this doesn't work?

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.