color_scheme_form_validate

color_scheme_form_validate($form, FormStateInterface $form_state)

Form validation handler for color_scheme_form().

See also

color_scheme_form_submit()

File

core/modules/color/color.module, line 359
Allows users to change the color scheme of themes.

Code

function color_scheme_form_validate($form, FormStateInterface $form_state) {
  // Only accept hexadecimal CSS color strings to avoid XSS upon use.
  foreach ($form_state->getValue('palette') as $key => $color) {
    if (!color_valid_hexadecimal_string($color)) {
      $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', array('%name' => $form['color']['palette'][$key]['#title'])));
    }
  }
}
doc_Drupal
2016-10-29 08:50:09
Comments
Leave a Comment

Please login to continue.