I would like to get some feedback on a feature I would like to drop from the rendering of forms (concerns both twig and php).
You can give some variables when rendering a view and they will be forwarded to each sub sections of the view. For example when you render a row: form_row(form.name, {'label' : 'custom'}) Then the label text is forwarded and used when rendering the label section of form.name. For reference, the block fiel_row is: {% block field_row %} {% spaceless %} <div> {{ form_label(form) }} {{ form_errors(form) }} {{ form_widget(form) }} </div> {% endspaceless %} {% endblock field_row %} One problem which this approach is that recently label was modified to accept attributes (class, ...). Then if you do something like form_row(form.name, {'label' : 'custom', 'attr': {'class' : 'pretty'}) The pretty class would be applied to both the label and the widget sections which is probably not what you want to do. For reference, labels accepts variable since: https://github.com/symfony/symfony/commit/cb22ccc516d07069f0f588c825897ef2d3cd9982#src/Symfony/Bridge/Twig/Extension/FormExtension.php In fact this is the intended behavior that I broke by fixing an other issue: https://github.com/symfony/symfony/issues/1157 So as of today the behavior is that the extra variables (label and attr in the previous example) are forwarded to the first rendered section only (i.e. the label but errors and widget would not receive them). This was for the background, now the question: There are two ways to move forward: 1. Either fix the rendering to actually forward the variables to all the sections (label plus errors and widget in the previous example) 2. Drop this feature. In such a case you would not be able to customize your view by rendering form_row(form.name) but you would have to explicitly render the label, the errors and the widget (i.e. expanding the field_row block to include your customization) What solution do you think is the best ? If being able to customize the label while rendering a row (form_row(form.name, {'label' : 'custom'})) is a common requirement, this could be achieved with the second solution by slightly changing the block: {% block field_row %} {% spaceless %} <div> {{ form_label(form, label) }} {{ form_errors(form) }} {{ form_widget(form) }} </div> {% endspaceless %} {% endblock field_row %} Hope this is clear enough ? -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to symfony-devs@googlegroups.com To unsubscribe from this group, send email to symfony-devs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en