Created on 6 June 2023, over 1 year ago
Updated 14 June 2023, over 1 year ago

Problem/Motivation

- Check for |default() usage, especially, true or false if needed or broken.

📌 Task
Status

Fixed

Version

5.0

Component

Code

Created by

🇫🇷France Grimreaper France 🇫🇷

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • 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
  • - component dropdown > default('true'), default(false) => ok
    - component navbar > default('true'), default(false) => ok

  • @grimreaper opened merge request.
  • Assigned to Grimreaper
  • 🇫🇷France Grimreaper France 🇫🇷
  • Issue was unassigned.
  • Status changed to Fixed over 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024