- Issue created by @Grimreaper
- 🇫🇷France pdureau Paris
Pattern settings: more usage of default_value in YAML definition instead of Twig template?
Those mechanisms are different:
- default_value in YAML definition: Default value in the forms input. So, only for site building. AFAIK it doesn't work if the pattern is directly called from PHP render arrays.
- |default() filter in Twig template: Default value to enforce if no value. Because settings (and fields) are not expecting to be mandatory.
So, what can we do?
- we keep both. The only issue with this current situation is to force the front dev to keep default_value and default() synced. And I am genuinely asking myself if it is an issue if they are out of sync. For example, for an "icon_size" integer setting, if default_value: 4, kept like that, and |default(5), the result will be 4 anyway, as set in the form.
- we introduce a new mechanism enforcing the YAML default_value if missing, so consolidating the 2 uses into the YAMl, making |default() filters redundant and soure of confusion is out of sync.
My opinion is to keep the current behaviour, but I am open to discussion.
- 🇫🇷France Grimreaper France 🇫🇷
Thanks for the reply.
I thought default_value in YAML resulted in the Twig variable being populated too, not just the form prefilled. So definitely keeping the default in Twig.
Also as ui_patterns_settings is required in ui_suite_bootstrap, IF default_value also ensured the variable in Twig, kind of okay, but no.
So removing the first point and keeping only audit of default in Twig.
- Status changed to Needs review
over 1 year ago 1:17pm 12 June 2023 - component dropdown > default('true'), default(false) => ok
- component navbar > default('true'), default(false) => ok- @grimreaper opened merge request.
- Assigned to Grimreaper
- Issue was unassigned.
- Status changed to Fixed
over 1 year ago 7:48am 14 June 2023 Automatically closed - issue fixed for 2 weeks with no activity.