You are here

function CourseObjectBook::optionsForm in Course 8.2

Same name and namespace in other branches
  1. 8.3 modules/course_book/src/Plugin/course/CourseObject/CourseObjectBook.php \Drupal\course_book\Plugin\course\CourseObject\CourseObjectBook::optionsForm()
  2. 3.x modules/course_book/src/Plugin/course/CourseObject/CourseObjectBook.php \Drupal\course_book\Plugin\course\CourseObject\CourseObjectBook::optionsForm()

Default options form for all course objects.

Overrides CourseObjectNode::optionsForm

File

modules/course_book/src/Plugin/course/CourseObject/CourseObjectBook.php, line 60

Class

CourseObjectBook
Plugin annotation @CourseObject( id = "book", label = "Book", handlers = { "fulfillment" = "\Drupal\course_book\Plugin\course\CourseObject\CourseObjectBookFulfillment" } )

Namespace

Drupal\course_book\Plugin\course\CourseObject

Code

function optionsForm(&$form, &$form_state) {
  $config = $this
    ->getOptions();
  parent::optionsForm($form, $form_state);
  $form['book_tracking'] = array(
    '#title' => t('Completion criteria'),
    '#type' => 'select',
    '#options' => array(
      'one' => t('View any page'),
      'all' => t('View all pages'),
    ),
    '#default_value' => $config['book_tracking'],
  );

  // Add a book-specific configuration for course outline list item type, only
  // if the standard course list outline handler is selected.
  if ($this
    ->getCourse()
    ->get('outline')
    ->getString() == 'course') {
    $form['outline_list_item_type'] = array(
      '#title' => t('Course outline list item type'),
      '#type' => 'select',
      '#options' => array(
        'all_pages' => t('All book pages as an expanded, nested list'),
        'active_tree' => t('Only the active book menu tree items, with a count indicator'),
        'count' => t('A count indicator only'),
      ),
      '#default_value' => $config['outline_list_item_type'],
    );
  }
}