Symfony 2隐藏表单字段文本
这可能真的很愚蠢,但我试图在 symfony 中设置一个隐藏的表单字段值,但是当我查看源代码时,该值没有显示。 this->postID 指的是我通过构造函数传入的值,但这并不重要,即使我将数据值设置为它不显示的字符串。我一定做了一些非常愚蠢的事情..这是我的表格..
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('text','text');
$builder->add('IsshPost','hidden', array('data'=>$this->postID));
}
知道出了什么问题吗?
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'=>$this->postID));
}
any idea whats wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想出来了..谢谢!基本上,您必须通过传递额外的字段来将字段与实体分离
I figured it out.. thanks! basically you have to detach the field from the entity by passing an extra field
在 Symfony 2.1 中,“data”选项在这方面得到了修复。有问题的代码应该可以开箱即用。
In Symfony 2.1, the "data" option is fixed in that regard. The code in question should work out of the box there.