function content_multigroup_group_edit_form_validate in Content Construction Kit (CCK) 6.3
Validate the Fieldgroup edit form.
1 string reference to 'content_multigroup_group_edit_form_validate'
- content_multigroup_group_edit_form in modules/
content_multigroup/ content_multigroup.admin.inc - Alter the Fieldgroup edit form to add Multigroup settings.
File
- modules/
content_multigroup/ content_multigroup.admin.inc, line 486 - Implementation of node type administration functions for content multigroup.
Code
function content_multigroup_group_edit_form_validate($form, &$form_state) {
$form_values = $form_state['values'];
$group_type = $form_values['group_type'];
if ($group_type != 'multigroup') {
return;
}
$content_type = $form['#content_type'];
$groups = fieldgroup_groups($content_type['type']);
$group = $groups[$form_values['group_name']];
foreach ($group['fields'] as $field_name => $data) {
// Make sure we don't set the multiple values to a number that
// would result in lost data.
$max_existing = content_max_delta($field_name);
if ($form_values['settings']['multigroup']['multiple'] != 1 && $max_existing > $form_values['settings']['multigroup']['multiple']) {
form_set_error('settings][multigroup][multiple', t('The field %field in this group already has %multiple values in the database. To prevent the loss of data you cannot set the number of Multigroup values to less than this.', array(
'%field' => $data['label'],
'%multiple' => $max_existing,
)));
}
}
}