function BlockForm::validateVisibility
Same name in other branches
- 9 core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::validateVisibility()
- 8.9.x core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::validateVisibility()
- 10 core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::validateVisibility()
Helper function to independently validate the visibility UI.
Parameters
array $form: A nested array form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to BlockForm::validateVisibility()
- BlockForm::validateForm in core/
modules/ block/ src/ BlockForm.php - Form validation handler.
1 method overrides BlockForm::validateVisibility()
- BlockEntitySettingTrayForm::validateVisibility in core/
modules/ settings_tray/ src/ Block/ BlockEntitySettingTrayForm.php - Helper function to independently validate the visibility UI.
File
-
core/
modules/ block/ src/ BlockForm.php, line 315
Class
- BlockForm
- Provides form for block instance forms.
Namespace
Drupal\blockCode
protected function validateVisibility(array $form, FormStateInterface $form_state) {
// Validate visibility condition settings.
foreach ($form_state->getValue('visibility') as $condition_id => $values) {
// 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));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.