You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
In SF4.3 a row_attr was added to form types. These attributes are not outputted in the bootstrap 4 form theme
How to reproduce
Set row attr like this on a form type:
$builder
->add('field', TextType::class, [
'row_attr' => [
'data-test' => 'this attribute is not displayed'
]
])
;
Remember to use the bootstrap_4_layout.html.twig form theme. When rendering the form:
{{ form_row(form.field) }}
notice that there is no data-test attribute.
Possible Solution
Use something like the default theme:
{% with {attr: row_attr|default({})} %}{{ block('attributes') }}{% endwith %}
but of course use the bootstrap class, so maybe something like this:
{% with {attr: row_attr|default({'class': 'form-group'})} %}{{ block('attributes') }}{% endwith %}?
The problem with this is that if you set the row attr it would override the default attribute, which is not intended. So you need some kind of intelligent merge that can handle i.e. the default class and the user setting another class in the form type.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: ^4.3.0
Description
In SF4.3 a
row_attr
was added to form types. These attributes are not outputted in the bootstrap 4 form themeHow to reproduce
Set row attr like this on a form type:
Remember to use the
bootstrap_4_layout.html.twig
form theme. When rendering the form:notice that there is no
data-test
attribute.Possible Solution
Use something like the default theme:
{% with {attr: row_attr|default({})} %}{{ block('attributes') }}{% endwith %}
but of course use the bootstrap class, so maybe something like this:
{% with {attr: row_attr|default({'class': 'form-group'})} %}{{ block('attributes') }}{% endwith %}
?The problem with this is that if you set the row attr it would override the default attribute, which is not intended. So you need some kind of intelligent merge that can handle i.e. the default class and the user setting another class in the form type.
The text was updated successfully, but these errors were encountered: