1
Meine Form in PHP hinzuzufügen:wie Attribut symfony Form collection Element
class MyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('configFiles', CollectionType::class, array(
'entry_type' => TextareaType::class,
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'prototype' => true
))
}
...
}
Meine Form in Zweig:
...
<div class="form-group">
{{ form_label(create_lab_form.configFiles) }}
<div class="configFiles" data-prototype="{{ form_widget(create_lab_form.configFiles.vars.prototype)|e('html_attr') }}">
</div>
{{ form_errors(create_lab_form.configFiles) }}
</div>
{% do create_lab_form.configFiles.setRendered %}
</div>
...
Wie Attribute (zB "Zeilen") für Textarea Sammelelement hinzufügen im obigen Beispiel?
Ich habe versucht, so etwas wie diese, aber es funktioniert nicht:
->add('configFiles', CollectionType::class, array(
'entry_type' => TextareaType::class, array(
'attr' => array('rows' => 10
)),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'prototype' => true
))
Vielen Dank im Voraus!