function fieldgroup_field_overview_form_validate in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 6.3 modules/fieldgroup/fieldgroup.module \fieldgroup_field_overview_form_validate()
1 string reference to 'fieldgroup_field_overview_form_validate'
- fieldgroup_form_alter in modules/
fieldgroup/ fieldgroup.module - Implementation of hook_form_alter()
File
- modules/
fieldgroup/ fieldgroup.module, line 414 - Create field groups for CCK fields.
Code
function fieldgroup_field_overview_form_validate($form, &$form_state) {
$form_values = $form_state['values'];
$group = $form_values['_add_new_group'];
if (array_filter(array(
$group['label'],
$group['group_name'],
))) {
$validation = fieldgroup_validate_name($group, $form['#type_name']);
if (!empty($validation['errors'])) {
foreach ($validation['errors'] as $type => $messages) {
foreach ($messages as $message) {
if ($type == 'label') {
form_set_error('_add_new_group][label', t('Add new group:') . ' ' . $message);
}
else {
form_set_error('_add_new_group][group_name', t('Add new group:') . ' ' . $message);
}
}
}
}
$group_name = $validation['group_name'];
form_set_value($form['_add_new_group']['group_name'], $group_name, $form_state);
}
else {
// Fail validation if attempt to nest fields under a new group without the
// proper information. Not raising an error would cause the nested fields
// to get weights the user doesn't expect.
foreach ($form_values as $key => $values) {
if ($values['parent'] == '_add_new_group') {
form_set_error('_add_new_group][label', t('Add new group: you need to provide a label.'));
form_set_error('_add_new_group][group_name', t('Add new group: you need to provide a group name.'));
break;
}
}
}
}