You are here

function ccl_add_form_validate in Custom Contextual Links 7

Same name and namespace in other branches
  1. 8 ccl.admin.inc \ccl_add_form_validate()

Validafion handler for ccl_add_form().

See also

ccl_add_form()

File

./ccl.admin.inc, line 281
Provides administrative functions for ccl.

Code

function ccl_add_form_validate($form, &$form_state) {
  $values = $form_state['values'];

  // Check that that we can get the node id and transform it for saving.
  if ($values['ccl_type'] == 'node' && $values['node_options'] == 'node') {
    if (is_numeric($values['node_id'])) {
      form_set_value($form['options_group']['node_id'], $values['node_id'], $form_state);
    }
    elseif (preg_match('/\\[nid:[0-9]*\\]/', $values['node_id'], $match)) {
      form_set_value($form['options_group']['node_id'], substr(rtrim($match[0], ']'), 5), $form_state);
    }
    else {
      form_set_error('nid', t('Enter a node id or use the autocomplete widget to select an existing node.'));
    }
  }
}