diff --git a/core/lib/Drupal/Core/Condition/ConditionPluginBase.php b/core/lib/Drupal/Core/Condition/ConditionPluginBase.php index 48d6cc64fa..6ab0b9ee2a 100644 --- a/core/lib/Drupal/Core/Condition/ConditionPluginBase.php +++ b/core/lib/Drupal/Core/Condition/ConditionPluginBase.php @@ -65,6 +65,10 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta * {@inheritdoc} */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { + // In the config schema, 'negate' is a boolean. However, some form elements + // such as checkbox return the value as 0/1. Cast here to ensure the data is + // in the expected type. + $form_state->setValue('negate', (bool) $form_state->getValue('negate')); } /** diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index 5624fc577e..c98ba1b1d7 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -323,13 +323,6 @@ public function validateForm(array &$form, FormStateInterface $form_state) { protected function validateVisibility(array $form, FormStateInterface $form_state) { // Validate visibility condition settings. foreach ($form_state->getValue('visibility') as $condition_id => $values) { - // All condition plugins use 'negate' as a Boolean in their schema. - // However, certain form elements may return it as 0/1. Cast here to - // ensure the data is in the expected type. - if (array_key_exists('negate', $values)) { - $form_state->setValue(['visibility', $condition_id, 'negate'], (bool) $values['negate']); - } - // Allow the condition to validate the form. $condition = $form_state->get(['conditions', $condition_id]); $condition->validateConfigurationForm($form['visibility'][$condition_id], SubformState::createForSubform($form['visibility'][$condition_id], $form, $form_state));