Problem/Motivation
ParagraphsWidget introduces getSettingOptions method to retrieve list of available options. If another widget uses the same settings_name as ParagraphsWidget, ie. edit_mode, closed_mode, autocollapse or add_mode, but provides custom list of options switching back to Paragraphs EXPERIMENTAL widget will cause AjaxError, because selected option could not be found in the array returned by getSettingOptions.
Here's the problematic code fragment:
$edit_mode = $this->getSettingOptions('edit_mode')[$this->getSetting('edit_mode')];
$closed_mode = $this->getSettingOptions('closed_mode')[$this->getSetting('closed_mode')];
$add_mode = $this->getSettingOptions('add_mode')[$this->getSetting('add_mode')];
Ex. if $this->getSetting('add_mode') returns radios, because it was a valid option for previously selected widget, the code above will fail with Undefined offset error.
Proposed resolution
Add method to retrieve option label and fallback to key if the label cannot be found.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comments
Comment #2
zaporylieThis patch introduces new method,
getSettingOptionLabel, that returns the label OR the key if label could not be found.Comment #3
j.cowher commentedThis issue still exists in 1.14. I am seeing the following error in when viewing
/admin/structure/types/manage/[bundle]/form-display. I am using Drupal 9.3 and PHP 8.0.It appears that
ParagraphsWidget::getSettingOptions()only considers the core options provided by the Paragraphs module and not other modules such as Paragraphs Browser.The patch from #2 worked for me.
Comment #4
damienmckennaStill seeing this problem with Paragraphs Browser on D11.3, and the patch resolves the problem for me.