function field_group_validate_id in Field Group 8
Same name and namespace in other branches
- 7.2 field_group.field_ui.inc \field_group_validate_id()
- 7 field_group.field_ui.inc \field_group_validate_id()
Validate the entered id attribute 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_id'
- FieldGroupFormatterBase::settingsForm in src/
FieldGroupFormatterBase.php - Returns a form to configure settings for the formatter.
File
- includes/
helpers.inc, line 58
Code
function field_group_validate_id($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']['id']) && !preg_match('!^[A-Za-z0-9-_]+$!', $form_state_values['fields'][$plugin_name]['settings_edit_form']['settings']['id'])) {
Drupal::formBuilder()
->setError($element, $form_state, t('The id must include only letters, numbers, underscores and dashes.'));
}
}