Ich habe SuperType
Formular für die Entität Super
.Wie übergebe ich Optionen an CustomType im Sammlungsfeld Symfony 2.1?
In dieser Form habe ich ein collection
Feld ChildType
Formulartypen für Entity Child
class SuperType:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('childrens', 'collection', array(
'type' => new ChildType(null, array('my_custom_option' => true)),
}
class ChildType:
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($options['my_custom_option']) {
$builder->add('my_custom_field', 'textarea'));
}
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
...
'my_custom_option' => false
));
}
Wie kann ich die 012 ändernWert nur für diese SuperType
Form?
Natürlich, was ich versucht habe, diese Option über Konstruktor übergeben, funktioniert nicht.
Erwägen Sie, Ihre Antwort zu aktualisieren, da dies jetzt veraltet ist – Trix