You are here

function ccl_actions_form_validate in Custom Contextual Links 7

Same name and namespace in other branches
  1. 8 ccl_actions/ccl_actions.module \ccl_actions_form_validate()

Validafion handler for ccl_actions_form().

See also

ccl_actions_form()

File

ccl_actions/ccl_actions.module, line 148
Implementation of core actions for CCL.

Code

function ccl_actions_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['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.'));
    }
  }
}