Problem/Motivation

The 6.0.x branch is broken, and won't render, giving only an ugly error message.

This commit breaks Radix for me. All prior commits are fine, this and all subsequent commits are broken. The error message I get blames form.twig.

The website encountered an unexpected error. Please try again later.

Twig\Error\RuntimeError: The merge filter only works with arrays or "Traversable", got "NULL" as second argument. in twig_array_merge() (line 22 of themes/contrib/radix/components/form/form.twig).

__TwigTemplate_c337c02e58a347dd9deb9a216e3d8f73->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 39)
__TwigTemplate_120a30412e0b658be1d21c68bcbf0688->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)

Issue fork radix-3402732

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Amstercad created an issue. See original summary.

amstercad’s picture

In components/form/form.twig, replacing this line:

{% set form_utility_classes = form_utility_classes ? form_utility_classes : [] %}

with this line allows the website to render again:

{% set utility_classes = utility_classes ? utility_classes : [] %}

I'd submit a patch to change it back, but I'm not sure what you were trying to achieve.

doxigo’s picture

Lee is there any template that is passing utility_classes to form.twig? since simply renaming a variable shouldn't break the whole thing and since we are still on the dev branch, we are not that much backward compatible though

the reason for name changing is to be clear on what a utility class is used for

amstercad’s picture

"utility_classes" are called from all over the place. For example this .yml file.

doxigo’s picture

Does changing utility_classes to form_utility_classes in the yml file and clearing the cache fixes the issue?

doxigo’s picture

Also that utlity_classes coming from nav component and not from the form component

I believe the error you are getting is not related to the class changes

amstercad’s picture

I created a clean Drupal site with only Radix 6.0.x and the rendering fails with the same error as written above. That's what I can report for the moment.

amstercad’s picture

Notice the changes in this code for form.twig. utility_classes is now form_utility_classes. However form_utility_classes is used in four places, not three as in the GIT commit in question. With the code below, the website renders fine.

That's all I have tested for. I didn't test the form component.

{% set form_utility_classes = form_utility_classes ? form_utility_classes : [] %}

{%
  set classes = [
    'form',
    is_inline ? 'form-inline',
  ]|merge(form_utility_classes)
%}

<form{{ attributes.addClass(classes) }}>
  {{ children }}
</form>
doxigo’s picture

Thanks a lot for the discovery, do you mind to create a MR so I can check?

doxigo’s picture

Thanks for the MR Lee :) appreciate your help, merged

doxigo’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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