function field_group_field_overview_validate in Field Group 7
Same name and namespace in other branches
- 7.2 field_group.field_ui.inc \field_group_field_overview_validate()
Validate handler for the overview screens.
Parameters
Array $form The complete form.:
Array $form_state The state of the form.:
1 string reference to 'field_group_field_overview_validate'
- field_group_field_ui_overview_form_alter in ./
field_group.field_ui.inc - Function to alter the fields overview and display overview screen.
File
- ./
field_group.field_ui.inc, line 543 - Field_group.field_ui.inc is a file that contains most functions needed on the Fields UI Manage forms (display and fields).
Code
function field_group_field_overview_validate($form, &$form_state) {
$form_values = $form_state['values']['fields'];
$entity_type = $form['#entity_type'];
$bundle = $form['#bundle'];
$mode = isset($form['#view_mode']) ? $form['#view_mode'] : 'form';
$group = $form_values['_add_new_group'];
// Validate if any information was provided in the 'add new group' row.
if (array_filter(array(
$group['label'],
$group['group_name'],
))) {
// Missing group name.
if (!$group['group_name']) {
form_set_error('fields][_add_new_group][group_name', t('Add new group: you need to provide a group name.'));
}
else {
$group_name = $group['group_name'];
// Add the 'group_' prefix.
if (drupal_substr($group_name, 0, 6) != 'group_') {
$group_name = 'group_' . $group_name;
form_set_value($form['fields']['_add_new_group']['group_name'], $group_name, $form_state);
}
// Invalid group name.
if (!preg_match('!^group_[a-z0-9_]+$!', $group_name)) {
form_set_error('fields][_add_new_group][group_name', t('Add new group: the group name %group_name is invalid. The name must include only lowercase unaccentuated letters, numbers, and underscores.', array(
'%group_name' => $group_name,
)));
}
if (drupal_strlen($group_name) > 32) {
form_set_error('fields][_add_new_group][group_name', t("Add new group: the group name %group_name is too long. The name is limited to 32 characters, including the 'group_' prefix.", array(
'%group_name' => $group_name,
)));
}
// Group name already exists.
if (field_group_exists($group_name, $entity_type, $bundle, $mode)) {
form_set_error('fields][_add_new_group][group_name', t('Add new group: the group name %group_name already exists.', array(
'%group_name' => $group_name,
)));
}
}
}
}