You are here

function gnode_node_validate in Group 7

Implements hook_node_validate().

Validates and processes the 'parent group' field.

See also

gnode_form_node_form_alter()

File

modules/gnode/gnode.module, line 420
Contains Group's implementation of the Node module hooks and forms.

Code

function gnode_node_validate($node, $form, &$form_state) {

  // If the user was presented with an autocomplete, we need to map the selected
  // group name to a group id in the form state so the submit handler can rely
  // on it being set.
  if (!empty($form_state['values']['group_settings']['group'])) {

    // Retrieve the group id from the name suffix.
    if ($gid = group_autocomplete_result_gid($form_state['values']['group_settings']['group'])) {
      $form_state['values']['group_settings']['gid'] = $gid;
    }
    else {
      form_set_error('group_settings][group', t('Group name not found'));
    }
  }
}