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

CommentFileSizeAuthor
#4 3439449__4.patch2.3 KBstomusic

Comments

abhishek_gupta1’s picture

Assigned: Unassigned » abhishek_gupta1
abhishek_gupta1’s picture

Assigned: abhishek_gupta1 » Unassigned
Status: Active » Needs review

fix the issue and created Patch. please review it once.

stomusic’s picture

StatusFileSize
new2.3 KB

I 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.

doxigo’s picture

I 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?

  • c6651417 committed on 6.0.x
    Issue #3439449: Drupal\sdc\Exception\InvalidComponentException: [type]...
doxigo’s picture

Status: Needs review » Fixed

Pushed a fix for this, thank you all for the help.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.