Undefined array key "#title"

Created on 31 July 2023, over 1 year ago
Updated 27 August 2023, over 1 year ago

Problem/Motivation

Creating a new Markdown text format produced the below error.

Steps to reproduce

  1. On a new site, I logged in as User 1, navigated to Admin->Configuration->Content authoring->Text formats and editors.
  2. I typed "Markdown" for the Name and let it generate the machine name automatically.
  3. For enabled filters I ticked Markdown Easy and Limit allowed HTML tags and correct faulty HTML .
  4. I changed to order to put Markdown first.
  5. Under Markdown settings I changed the flavor to GitHub.
  6. I clicked save, and the error below is displayed. Note that the format does save.
 Warning: Undefined array key "#title" in _markdown_easy_filter_format_form_submit() (line 46 of modules/contrib/markdown_easy/markdown_easy.module).

_markdown_easy_filter_format_form_submit(Array, Object)
call_user_func_array('_markdown_easy_filter_format_form_submit', Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('filter_format_add_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 583)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 166)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

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

Comments & Activities

  • Issue created by @lostcarpark
  • 🇮🇳India keshavv India

    I have followed all the steps mentioned, But I cannot reproduce it. In my case the value of #titlefield is present.
    There is no error log as well.

  • 🇺🇸United States ultimike Florida, USA

    @lostcarpark - do you get this error consistently?

    Were you testing on a fresh D10 install?

    Do you have any other modules enabled that might mess with the $form['#title'] of text format forms?

    -mike

  • 🇮🇪Ireland lostcarpark

    It was a fresh install of D10 under DDEV.

    I think I've figured out how to reproduce:

    1. Go to Text formats and editors.
    2. Add text format.
    3. Under enabled filters check "Markdown Easy" and "Limit allowed HTML tags and correct faulty HTML" (but do not select "Convert line breaks into HTML").
    4. Change order to put Markdown Easy first.
    5. Click "Save configuration".

    The error above will be displayed.

    Note that in the Markdown Easy description, it says "It is strongly recommended to configure the 'Limit allowed HTML tags and correct faulty HTML' filter so that it runs after this filter", but it doesn't mention "Convert line breaks into HTML". It's only when Markdown Easy is enabled that the message about the other module is shown (and in a warning when the format is saved without it).

    If you en

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States ultimike Florida, USA

    @lostcarpark - I've found and fixed the issue and added a test - want to give this a quick looksie?

    thanks,
    -mike

  • @ultimike opened merge request.
  • 🇮🇪Ireland lostcarpark

    Repeated the steps in #5, and verified no longer getting error message. Looks good now.

  • Status changed to RTBC over 1 year ago
  • 🇮🇪Ireland lostcarpark

    Also ran tests and verified passing. The change and the new test look good to me. Moving to RTBC.

    • ultimike committed 2fde44f9 on 1.0.x
      Issue #3378342 by ultimike, lostcarpark: Undefined array key "#title"
      
  • Status changed to Fixed over 1 year ago
  • 🇺🇸United States ultimike Florida, USA

    Sweet - thanks - merging.

    -mike

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

  • Status changed to Fixed over 1 year ago
  • 🇺🇸United States ultimike Florida, USA
Production build 0.71.5 2024