如何在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>中Echo form_widget(form.testImages)