function EntityReference::validateExtraOptionsForm
Overrides HandlerBase::validateExtraOptionsForm
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ EntityReference.php, line 327
Class
- EntityReference
- Filters a view by entity references.
Namespace
Drupal\views\Plugin\views\filterCode
public function validateExtraOptionsForm($form, FormStateInterface $form_state) : void {
$options = $form_state->getValue('options');
$sub_handler = $options['sub_handler'];
$subform = $form[static::SUBFORM_PREFIX . $sub_handler];
$subform_state = SubformState::createForSubform($subform, $form, $form_state);
// Copy handler_settings from options to settings to be compatible with
// selection plugins.
$subform_options = $form_state->getValue([
'options',
static::SUBFORM_PREFIX . $sub_handler,
]);
$subform_state->setValue([
'settings',
], $subform_options);
$this->getSelectionHandler($sub_handler)
->validateConfigurationForm($subform, $subform_state);
// Store the sub handler options in sub_handler_settings.
$form_state->setValue([
'options',
'sub_handler_settings',
], $subform_options);
// Remove options that are not from the selected sub_handler.
foreach (array_keys($this->getSubHandlerOptions()) as $sub_handler_option) {
if (isset($options[static::SUBFORM_PREFIX . $sub_handler_option])) {
$form_state->unsetValue([
'options',
static::SUBFORM_PREFIX . $sub_handler_option,
]);
}
}
parent::validateExtraOptionsForm($form, $form_state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.