Using symfony 3.4 (php)
I have a form to edit the user profile of the current user with client-dependent attributes. So I generate the form with a UserType inheriting from Symfony\Component\Form\AbstractType
, adding the attributes with an EventListener depending on the client:
$form->add('ca-' . $attribute->getId(), TextType::class, array('label' => $attribute->getAttributeName() . ':'));
Now how can I generate the rows for this in my twig template? It should be something like
{{ form_row(form['ca-' . attribute.id]) }}
but it seems that I can't bind the integer attribute.id
with a period. Is there a way to access this variable here? Accessing attribute address
works fine with the following code:
{{ form_row(form.address) }}
Thank you