Options should be passed to the createForm() method, not to your DogForm constructor:$form = $this->createForm(new DogForm(), $dog, array('has_cats' => $cats));请注意,您还必须将has_cats"添加到 getDefaultOptions() 中Mind, that you have to add "has_cats" to getDefaultOptions() as well 这篇关于通过 buildForm() 中的 $options 访问变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 11:07