You are here

public function ColorButton::validateInput in CKEditor Color Button 8

Ensure values entered for color hex values contain no unsafe characters.

Parameters

$element:

\Drupal\Core\Form\FormStateInterface $form_state:

File

src/Plugin/CKEditorPlugin/ColorButton.php, line 111

Class

ColorButton
Defines the "colorbutton" plugin.

Namespace

Drupal\colorbutton\Plugin\CKEditorPlugin

Code

public function validateInput(array $element, FormStateInterface $form_state) {
  $input = $form_state
    ->getValue([
    'editor',
    'settings',
    'plugins',
    'colorbutton',
    'colors',
  ]);
  if (preg_match('/([^A-F0-9,])/i', $input)) {
    $form_state
      ->setError($element, 'Only valid hex values are allowed (A-F, 0-9). No other symbols or letters are allowed. Please check your settings and try again.');
  }
}