[英]How to use entity field type array with multiple different form widgets in symfony2
[英]how to hide an array type of entity in a form in symfony2
我在实体中有一个数组类型,我想将其添加为表单类型作为隐藏字段。 我尝试了以下方法,但没有用。 它只会杀死浏览器。
任何帮助将不胜感激。
//Entity
class Test{
/**
* @ORM\Column(name="test_image_files", type="array",nullable=true)
*/
private $testImages;
/**
* @return mixed
*/
public function getTestImages()
{
return $this->testImages;
}
/**
* @param mixed $testImages
*/
public function setTestImages($testImages)
{
$this->testImages = $testImages;
}
}
// FormType
class TestType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('testImages','hidden');
}
}
//枝条
{{ form_widget(form.testImages) }}
这将帮助您处理当前情况,
在<div style="display:none"></div>
回form_widget(form.testImages)
。
我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.