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?