function type_style_form_validate in Type Style 8
Validate handler for forms with menu options.
See also
1 string reference to 'type_style_form_validate'
- type_style_attach_to_form in ./
type_style.module - Attaches Type Style elements to a form.
File
- ./
type_style.module, line 79 - Hook implementations for the Type Style module.
Code
function type_style_form_validate(&$form, FormStateInterface $form_state) {
$color = $form_state
->getValue([
'type_style',
'color',
]);
$color_regex = '/^#[0-9a-f]{6}$/i';
if (!empty($color) && !preg_match($color_regex, $color)) {
$form_state
->setErrorByName('type_style', t('The style color must be represented in hexadecimal, i.e. #000000.'));
}
}