You are here

public function CourseObjectNode::optionsValidate in Course 7

Same name and namespace in other branches
  1. 6 includes/course_object.core.inc \CourseObjectNode::optionsValidate()
  2. 7.2 includes/CourseObjectNode.inc \CourseObjectNode::optionsValidate()

Validate the options form. Check the node type.

Overrides CourseObject::optionsValidate

File

includes/CourseObjectNode.inc, line 254

Class

CourseObjectNode
A course object that uses a node as a base.

Code

public function optionsValidate(&$form, &$form_state) {
  parent::optionsValidate($form, $form_state);
  $nid = $form_state['values']['instance'];
  if (empty($nid) && isset($form_state['values']['node_type']) && empty($form_state['values']['node_type'])) {
    form_set_error('node_type', t('Please select a node type.'));
  }
  $missing_node = !preg_match('/^(?:\\s*|(.*) )?\\[\\s*nid\\s*:\\s*(\\d+)\\s*\\]$/', $nid);
  if (($form_state['values']['use_existing_node'] || !$this
    ->isTemporary()) && $missing_node) {
    form_set_error('instance', t('Please select a node.'));
  }
}