Problem/Motivation
When using
{% embed 'radix:alert' with {
type: types[type],
} %}(this is in the current default template for /templates/misc/status-messages.html.twig)
the following error is logged:
Drupal\sdc\Exception\InvalidComponentException: [type] NULL value found, but a string or an object is required. This may be because the property is empty instead of having data present. If possible fix the source data, use the |default() twig filter, or update the schema to allow multiple types./n[type] Does not have a value in the enumeration ["primary","secondary","success","danger","warning","info","light","dark"] in Drupal\sdc\Component\ComponentValidator->validateProps() (line 205 of /var/www/html/web/core/modules/sdc/src/Component/ComponentValidator.php)
Steps to reproduce
Call:
{% embed 'radix:alert' with {
type: types[type],
} %}From a template.
Proposed resolution
I did this - However I wonder if we also need to address light/dark - am guessing this was added for 5.3 colour modes ?
{% embed 'radix:alert' with {
type: types[type]|default('info'),
} %}
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3439449__4.patch | 2.3 KB | stomusic |
Comments
Comment #2
abhishek_gupta1 commentedComment #3
abhishek_gupta1 commentedfix the issue and created Patch. please review it once.
Comment #4
stomusicI have added your changes to the patch. I also found a similar problem with the node creation form, so similar changes have been added to this path and there.
Comment #5
doxigo commentedI need to get to this issue and check it out but isn't that a better idea to define the default value in the source rather than the calling template?
Comment #7
doxigo commentedPushed a fix for this, thank you all for the help.