You are here

public function CourseObjectNode::optionsValidate in Course 3.x

Same name and namespace in other branches
  1. 8.3 modules/course_content/src/Course/Object/CourseObjectNode.php \Drupal\course_content\Course\Object\CourseObjectNode::optionsValidate()
  2. 8.2 modules/course_content/src/Course/Object/CourseObjectNode.php \Drupal\course_content\Course\Object\CourseObjectNode::optionsValidate()

Validate the options form. Check the node type.

Overrides CourseObject::optionsValidate

File

modules/course_content/src/Course/Object/CourseObjectNode.php, line 269

Class

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

Namespace

Drupal\course_content\Course\Object

Code

public function optionsValidate(&$form, FormStateInterface $form_state) {
  parent::optionsValidate($form, $form_state);
  $nid = $form_state
    ->getValues()['instance'];
  if (empty($nid) && isset($form_state
    ->getValues()['node_type']) && empty($form_state
    ->getValues()['node_type'])) {
    $form_state
      ->setErrorByName('node_type', t('Please select a node type.'));
  }
  if (($form_state
    ->getValues()['use_existing_node'] || !$this
    ->isTemporary()) && empty($nid)) {
    $form_state
      ->setErrorByName('instance', t('Please select a node.'));
  }
}