This is probably really stupid but I am trying to set a hidden form field value in symfony yet when I do a view source, the value doesnt show up. this->postID refers to a value I am passing in through the constructor, but that doesnt matter, even if I set the data value to a string it doesn't show. I must be doing something really stupid.. Here is my form..
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('text','text');
$builder->add('IsshPost','hidden', array('data'=&g开发者_运维问答t;$this->postID));
}
any idea whats wrong?
I figured it out.. thanks! basically you have to detach the field from the entity by passing an extra field
"property_path => false"
In Symfony 2.1, the "data" option is fixed in that regard. The code in question should work out of the box there.
精彩评论