我有一个Symfony2表单,有两个分层的动态字段.第一层在使用表单事件实现记录的方式时没有问题:http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html#dynamic-generation-for-submitted-forms
但接下来是第三个字段,它取决于第二个字段,它已经是一个动态字段.
为了演示这个问题,这里是我的剥离代码:
<?php
class ServiceeventType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('park', 'entity', array(
'class' => 'AppBundle:Park',
'property' => 'identifyingName',
'label' => 'Park',
'required' => true,
'invalid_message' => 'Choose a Park',
'placeholder' => 'Please choose',
))
// just a placeholder for the $builder->get('facility')->addEventListener to have something to bind to
// I'm aware, that this is just a symptom of my problem …Run Code Online (Sandbox Code Playgroud)