You are here

function _webform_edit_validate_node in Webform Node Element 7

Same name and namespace in other branches
  1. 6 components/node.inc \_webform_edit_validate_node()

Element validation callback. Ensure a valid node ID was entered.

1 string reference to '_webform_edit_validate_node'
_webform_edit_node in components/node.inc
Implements _webform_edit_component().

File

components/node.inc, line 98
Webform module node component.

Code

function _webform_edit_validate_node($element, &$form_state) {
  if (!empty($element['#value'])) {

    // If ctools, the value might be in the form of "node title [nid: N]".
    if (module_exists('ctools')) {
      _webform_node_autocomplete_validate($element);
    }
    $node = node_load($element['#value']);
    if (empty($node->nid) || empty($node->status) && !user_access('administer nodes')) {
      form_error($element, t('Invalid node'));
    }

    // Store the node id that we'll use. #value is just for show :-)
    $form_state['values']['extra']['nid'] = $node->nid;
  }
  return TRUE;
}