function EditorHooks::editorFormFilterAdminFormatValidate
Same name and namespace in other branches
- main core/modules/editor/src/Hook/EditorHooks.php \Drupal\editor\Hook\EditorHooks::editorFormFilterAdminFormatValidate()
Additional validate handler for 'filter_format_form' form.
Parameters
array $form: The form render array.
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
File
-
core/
modules/ editor/ src/ Hook/ EditorHooks.php, line 539
Class
- EditorHooks
- Hook implementations for editor.
Namespace
Drupal\editor\HookCode
public function editorFormFilterAdminFormatValidate(array $form, FormStateInterface $form_state) : void {
$editor_set = $form_state->getValue([
'editor',
'editor',
]) !== "";
$subform_array_exists = !empty($form['editor']['settings']['subform']) && is_array($form['editor']['settings']['subform']);
if ($editor_set && $subform_array_exists && $editor_plugin = $form_state->get('editor_plugin')) {
$subform_state = SubformState::createForSubform($form['editor']['settings']['subform'], $form, $form_state);
$editor_plugin->validateConfigurationForm($form['editor']['settings']['subform'], $subform_state);
}
// This validation handler should not be used with the 'Configure' button.
if ($form_state->getTriggeringElement()['#name'] === 'editor_configure') {
return;
}
// When using this form with JavaScript disabled in the browser, the
// 'Configure' button won't be clicked automatically. So, when the user has
// selected a text editor and has then clicked 'Save configuration', we
// should point out that the user must still configure the text editor.
if ($form_state->getValue([
'editor',
'editor',
]) !== '' && !$form_state->get('editor')) {
$form_state->setErrorByName('editor][editor', $this->t('You must configure the selected text editor.'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.