Open SeriousKen opened 3 years ago
IMHO: This would be better:
{% set form_field_extra_wrapper_classes = form_field_extra_wrapper_classes ?? ('form-extra-wrapper ' ~ field.wrapper_classes) %}
Just simpler and gives all the power to the theme.
@mahagr that wouldn't work as field.wrapper_classes
wouldn't be applied if form_field_extra_wrapper_classes
was set. I've just copied the implementation for other form_field_...
variables in the default/field.html.twig file.
Well, it really depends if those classes are wanted or if you're allowed to do your own implementation. You are right, though, it requires theme devs to copy and modify the line...
https://github.com/getgrav/grav-plugin-form/blob/fab75139696d15bc9be0438f6649fb1ee2161327/templates/forms/default/field.html.twig#L91-L92
The default field template explicitly sets
form_field_extra_wrapper_classes
in a way that can't be overridden in a child template due to the way Twig handles template inheritance.I'm currently writing a plugin to integrate Bootstrap 5 and need a way to set classes on this section:
https://github.com/getgrav/grav-plugin-form/blob/fab75139696d15bc9be0438f6649fb1ee2161327/templates/forms/layouts/field.html.twig#L43-L49
without having to touch the field template. This could be fixed if line 92 in
default/field.html.twig
was changed to: