function Style::validateConfigurationForm

Same name in other branches
  1. 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Style.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Style::validateConfigurationForm()
  2. 11.x core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Style.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Style::validateConfigurationForm()

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Style.php, line 68

Class

Style
CKEditor 5 Style plugin configuration.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

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,
        $unparseable_lines,
    ] = self::parseStylesFormValue($form_value);
    if (!empty($unparseable_lines)) {
        $line_numbers = array_keys($unparseable_lines);
        $form_state->setError($form['styles'], $this->formatPlural(count($unparseable_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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.