function CKEditor5::assessActiveTextEditorAfterBuild
Same name in other branches
- 9 core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::assessActiveTextEditorAfterBuild()
- 11.x core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::assessActiveTextEditorAfterBuild()
Form #after_build callback: provides text editor state changes.
Updates the internal $this->entity object with submitted values when the form is being rebuilt (e.g. submitted via AJAX), so that subsequent processing (e.g. AJAX callbacks) can rely on it.
See also
\Drupal\Core\Entity\EntityForm::afterBuild()
File
-
core/
modules/ ckeditor5/ src/ Plugin/ Editor/ CKEditor5.php, line 511
Class
- CKEditor5
- Defines a CKEditor 5-based text editor for Drupal.
Namespace
Drupal\ckeditor5\Plugin\EditorCode
public static function assessActiveTextEditorAfterBuild(array $element, FormStateInterface $form_state) : array {
// The case of the form being built initially, and the text editor plugin in
// use is already CKEditor 5.
if (!$form_state->isProcessingInput()) {
$editor = $form_state->get('editor');
$already_using_ckeditor5 = $editor && $editor->getEditor() === 'ckeditor5';
}
else {
// Whenever there is user input, this cannot be the initial build of the
// form and hence we need to inspect user input.
$already_using_ckeditor5 = FALSE;
NestedArray::getValue($form_state->getUserInput(), [
'editor',
'settings',
'is_already_using_ckeditor5',
], $already_using_ckeditor5);
}
$form_state->set('ckeditor5_is_active', $already_using_ckeditor5);
$form_state->set('ckeditor5_is_selected', $form_state->getValue([
'editor',
'editor',
]) === 'ckeditor5');
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.