function editor_form_filter_admin_format_validate
Same name in other branches
- 8.9.x core/modules/editor/editor.module \editor_form_filter_admin_format_validate()
- 10 core/modules/editor/editor.module \editor_form_filter_admin_format_validate()
- 11.x core/modules/editor/editor.module \editor_form_filter_admin_format_validate()
Additional validate handler for filter_format_form().
1 string reference to 'editor_form_filter_admin_format_validate'
- editor_form_filter_format_form_alter in core/
modules/ editor/ editor.module - Implements hook_form_BASE_FORM_ID_alter() for \Drupal\filter\FilterFormatEditForm.
File
-
core/
modules/ editor/ editor.module, line 206
Code
function editor_form_filter_admin_format_validate($form, FormStateInterface $form_state) {
$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 validate handler is not applicable when using 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', 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.