I had a small but annoying problem with the symfony2 Field component. For example, I would like to output an array of form fields in a branch template:
{% for field in form %} {{ form_label( field ) }}: {{ form_field( field ) }} {% endfor %}
And here is the text box configuration:
$field = new TextField( 'FieldName', array( 'label' => 'MyCustomLabel', ) );
But unfortunately, when the engine displays this output, I get "FieldName" as a label instead of "MyCustomLabel". I would not have a problem if I displayed the form fields not in (in this case, I can just add a label to the template for each field). But the script does not know the specific number and configuration of the form fields before execution. So I need to implement a loop method for rendering fields. And I also want to stay in the bow record ... I will be happy for the good advice :)
forms symfony twig rendering
Aleksei Kornushkin
source share