开发者

Symfony 2 hidden form field text

开发者 https://www.devze.com 2023-04-10 04:19 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消