Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions

Can't insert dynamic value into HiddenField




28 April 2013 at 1:40am Community Member, 27 Posts

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?