MaterialIcons::getFormIconField assumes depth of icon field

Created on 27 June 2024, 11 months ago

The getFormIconField function in Drupal\material_icons\Plugin\Field\FieldWidget\MaterialIcons assumes the nested depth of the icon field to be 4 in the line.
return (!is_null($parents)) ? $form[$parents[3]][$parents[2]][$parents[1]]['icon'] : NULL;

This is not always the case an can result in the error
ResponseText: TypeError: Drupal\Core\Render\MainContent\AjaxRenderer::renderResponse(): Argument #1 ($main_content) must be of type array, null given, called in /app/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php on line 89 in Drupal\Core\Render\MainContent\AjaxRenderer->renderResponse() (line 49 of /app/web/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php).
at paths like
/layout_builder/update/block/overrides/node.9316/0/blb_region_col_1/3c9a37a5-f66c-45ba-80f9-a804ea7108af?destination=/node/9316/layout&_wrapper_format=drupal_ajax&ajax_form=1

The $parents array where I saw this issue looks like this:

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States damondt

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024