Same name and namespace in other branches
- 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Style.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Style::validateConfigurationForm()
Form validation handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides PluginFormInterface::validateConfigurationForm
File
- core/
modules/ ckeditor5/ src/ Plugin/ CKEditor5Plugin/ Style.php, line 68
Class
- Style
- CKEditor 5 Style plugin configuration.
Namespace
Drupal\ckeditor5\Plugin\CKEditor5PluginCode
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
// Match the config schema structure at ckeditor5.plugin.ckeditor5_style.
$form_value = $form_state
->getValue('styles');
[
$styles,
$invalid_lines,
] = self::parseStylesFormValue($form_value);
if (!empty($invalid_lines)) {
$line_numbers = array_keys($invalid_lines);
$form_state
->setError($form['styles'], $this
->formatPlural(count($invalid_lines), 'Line @line-number does not contain a valid value. Enter a valid CSS selector containing one or more classes, followed by a pipe symbol and a label.', 'Lines @line-numbers do not contain a valid value. Enter a valid CSS selector containing one or more classes, followed by a pipe symbol and a label.', [
'@line-number' => reset($line_numbers),
'@line-numbers' => implode(', ', $line_numbers),
]));
}
$form_state
->setValue('styles', $styles);
}