- Issue created by @Liam Morland
- 🇪🇸Spain idiaz.roncero Madrid
Agree that this is a bug. Especially if you consider that using an empty array using components directly on twig, you get no error at all: this only happens when using the RenderElement on your code.
There should be no difference on the accepted input values between the two ways to "invoke" a component.
- Merge request !12356Consider empty arrays a valid renderable on ComponentElement → (Open) created by idiaz.roncero
- 🇪🇸Spain idiaz.roncero Madrid
Created a simple MR that allows empty arrays to bypass the negative check from
Element::isRenderArray
.This is a solution, but it might be controversial and is no small change as it assumes that,contrary to what Drupal usually does, an empty array will be considered a valid render array in this particular context.
A different solution could be the opposite: making the twig
embed
andinclude
s of components apply the same logic and disallow passing empty arrays as slot values (right now, they swallow it)What we have now - different behavior depending on the way a component is called - is misleading. We need to chose one direction or the other.
(I am obviously not proposing here to let developers pass empty arrays voluntarily, but you can end up with an empty array as an unintended result of some business logic, both on twig and on PHP code, and we need to decide if this is something we want to support or not).