function field_group_validate_css_class in Field Group 8
Same name and namespace in other branches
- 7.2 field_group.field_ui.inc \field_group_validate_css_class()
- 7 field_group.field_ui.inc \field_group_validate_css_class()
Validate the entered css class from the submitted format settings.
Parameters
Array $element The validated element:
FormStateInterface $form_state The state of the form.:
1 string reference to 'field_group_validate_css_class'
- FieldGroupFormatterBase::settingsForm in src/
FieldGroupFormatterBase.php - Returns a form to configure settings for the formatter.
File
- includes/
helpers.inc, line 45
Code
function field_group_validate_css_class($element, FormStateInterface $form_state) {
$form_state_values = $form_state
->getValues();
$plugin_name = $form_state
->get('plugin_settings_edit');
if (!empty($form_state_values['fields'][$plugin_name]['settings_edit_form']['settings']['classes']) && !preg_match('!^[A-Za-z0-9-_ ]+$!', $form_state_values['fields'][$plugin_name]['settings_edit_form']['settings']['classes'])) {
$form_state
->setError($element, $form_state, t('The css class must include only letters, numbers, underscores and dashes.'));
}
}