Ajax callbacks not added dynamically

Created on 4 December 2018, over 6 years ago
Updated 28 February 2025, 3 months ago

How to reproduce:

- attach Plotly.js Graph field to any entity that is being later attached to a node (e.g. Paragraphs)
- open node form, click "Add Additional Series"

Result: nothing happens, Ajax request fails on following error:

Argument 1 passed to Drupal\Core\Renderer\MainContent\AjaxRenderer::renderResponse() must be of the type array, null given, called in /docroot/core/lib/Drupal/core/Form/FormAjaxResponseBuilder.php on line 89

Taking a quick look into the code, it looks like the problem is in PlotlyJsGraphWidget.php::addSeriesCallback() , which returns $form[$this->fieldName] array. However, on subforms, this array does not exist, the field is stored in $form['field_name_of_parent_field']['widget'][$parent_field_delta]['subform'][$this->fieldName]

In addition, calling the callback that way also triggers a form validator on adding, which has an additional negative side effect - the form validation errors will prevent adding the series as well, if any validation fails (e.g. mandatory field is empty). So not sure if this is an appropriate way of triggering this.

πŸ› Bug report
Status

Postponed: needs info

Version

1.4

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany mirsoft

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024