#2450637: Block page visibility option "Show for the listed pages" does not appear to save →
and
#2811519: Blocks do not appear after being placed with the Rules module enabled (or other missing schemata for Condition plugins) →
both deal with having to cast the form element value for condition plugins' negate
property to a boolean when submitting block forms. The typecasting is handled in \Drupal\block\BlockForm::validateVisibility()
. However, since validateVisibility()
calls each condition plugin's validateConfigurationForm()
method, it seems to make more sense to do the typecast in that method.
This also makes integrating condition plugins for other purposes easier, so that other forms do not also have to handle typecasting negate
.
Update \Drupal\Core\Condition\ConditionPluginBase::validateForm()
:
/**
* {@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'));
}
Separately, the typecasting in \Drupal\block\BlockForm::validateVisibility()
can probably be removed.
Needs tests and reviews
N/A
N/A
N/A
N/A
Closed: duplicate
9.3
Last updated
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.