On this page
function editor_form_filter_admin_format_submit
editor_form_filter_admin_format_submit($form, FormStateInterface $form_state)
Additional submit handler for filter_format_form().
File
- core/modules/editor/editor.module, line 219
- Adds bindings for client-side "text editors" to text formats.
Code
function editor_form_filter_admin_format_submit($form, FormStateInterface $form_state) {
// Delete the existing editor if disabling or switching between editors.
$format = $form_state->getFormObject()->getEntity();
$format_id = $format->isNew() ? NULL : $format->id();
$original_editor = editor_load($format_id);
if ($original_editor && $original_editor->getEditor() != $form_state->getValue(array('editor', 'editor'))) {
$original_editor->delete();
}
// Create a new editor or update the existing editor.
if ($editor = $form_state->get('editor')) {
// Ensure the text format is set: when creating a new text format, this
// would equal the empty string.
$editor->set('format', $format_id);
$editor->setSettings($form_state->getValue(['editor', 'settings']));
$editor->save();
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!editor!editor.module/function/editor_form_filter_admin_format_submit/8.1.x