Problem/Motivation
After selecting one of the following plugins, an Ajax error is shown in the console and the plugins configuration form is not shown correctly.
The error occurs while selecting
- User role
- Language
- every entity type related plugin like Node type, Vocabulary, Vote type etc..
Error message for entity bundle related plugins:
TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 78 of /var/www/html/docroot/core/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php)."
Steps to reproduce
Add field type Condition to a content type and try to select one of the condition plugins mentioned above.
After selecting one of the conditions from above, nothing happens and you'll get a Ajax Error in the console.
Proposed resolution
Looks like this issue neeeds to be fixed in the condition plugins drupal core provides, since source of the error is located there.
The core condition plugins implement the submitConfigurationForm method, which causes, the error, because array_filter gets an empty value, after Condition plugin is selected.
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['bundles'] = array_filter($form_state->getValue('bundles'));
parent::submitConfigurationForm($form, $form_state);
}