Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 303316

Undefined array key "#markup" in Drupal\config_translation\FormElement\ListElement->getGroupTitle()

$
0
0

Problem/Motivation

A Warning is thrown when the translation is enabled for a config form and one of the form elements key contains the string "title" or "label"

Steps to reproduce

  • Create a custom config form with the following element :
     $form['section_title'] = [
            '#type' => 'text_format',
            '#title' => 'Section Title',
            '#allowed_formats' => ['title_html'],
            '#format' => 'title_html',
            '#description' => $this->t('Enter the title here.'),
            '#description_display' => 'before',
            '#default_value' => $config->get("section_title")['value'] ?? '',
            '#required' => TRUE,
          ];
  • Add Schema file for the same
    mapping:
                section_title:
                  type: text_format
                  label: 'Section Title'
  • Now try to submit the translation form you'll see the warning above the form elements

Proposed resolution

Add a check if "#markup" exists in the source of the element before assigning to title.


Viewing all articles
Browse latest Browse all 303316

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>