function CodeBlock::validateConfigurationForm
Same name in other branches
- 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/CodeBlock.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\CodeBlock::validateConfigurationForm()
File
-
core/
modules/ ckeditor5/ src/ Plugin/ CKEditor5Plugin/ CodeBlock.php, line 46
Class
- CodeBlock
- CKEditor 5 Code Block plugin configuration.
Namespace
Drupal\ckeditor5\Plugin\CKEditor5PluginCode
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$form_value = $form_state->getValue('languages');
[
$styles,
$not_parseable_lines,
] = self::parseLanguagesFromValue($form_value);
if (!empty($not_parseable_lines)) {
$line_numbers = array_keys($not_parseable_lines);
$form_state->setError($form['languages'], $this->formatPlural(count($not_parseable_lines), 'Line @line-number does not contain a valid value. Enter a valid language key followed by a pipe symbol and a label.', 'Lines @line-numbers do not contain a valid value. Enter a valid language key followed by a pipe symbol and a label.', [
'@line-number' => reset($line_numbers),
'@line-numbers' => implode(', ', $line_numbers),
]));
}
$form_state->setValue('languages', $styles);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.