public function BUEditorEditorForm::validateForm in BUEditor 8
Same name and namespace in other branches
- 8.2 src/Form/BUEditorEditorForm.php \Drupal\bueditor\Form\BUEditorEditorForm::validateForm()
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- src/
Form/ BUEditorEditorForm.php, line 143
Class
- BUEditorEditorForm
- Base form for BUEditor Editor entities.
Namespace
Drupal\bueditor\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
$bueditor_editor = $this
->getEntity();
$toolbar =& $form_state
->getValue([
'settings',
'toolbar',
]);
// Convert toolbar to array.
if (is_string($toolbar)) {
$toolbar = array_values(array_filter(array_map('trim', explode(',', $toolbar))));
}
// Entity has the raw form values.
if (is_string($bueditor_editor
->getToolbar())) {
$bueditor_editor
->setToolbar($toolbar);
}
// Check class name
$cname = $form_state
->getValue([
'settings',
'cname',
]);
if (!empty($cname) && preg_match('/[^a-zA-Z0-9\\-_ ]/', $cname)) {
$form_state
->setError($form['settings']['cname'], $this
->t('Class name is invalid.'));
}
\Drupal::service('plugin.manager.bueditor.plugin')
->validateEditorForm($form, $form_state, $bueditor_editor);
}