You are here

function fieldgroup_edit_group_validate in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6 modules/fieldgroup/fieldgroup.module \fieldgroup_edit_group_validate()

Group name validation for programmatic group addition.

File

./fieldgroup.module, line 135
Create field groups for CCK fields.

Code

function fieldgroup_edit_group_validate($form_id, $form_values, $content_type, $action) {
  if (!empty($form_values['group_name']) && $action == 'add') {
    $groups = fieldgroup_groups($content_type['type']);
    $group = $groups[$form_values['group_name']];
    if (isset($group[$form_values['group_name']])) {
      form_set_error('group_name', t('The group name %name already exists.', array(
        '%group_name' => $form_values['group_name'],
      )));
    }
    if (!preg_match('!^[a-z0-9_]+$!', $form_values['group_name'])) {
      form_set_error('group_name', t('The group name %name is invalid.', array(
        '%group_name' => $form_values['group_name'],
      )));
    }
  }
}