You are here

function _course_outline_object_form in Course 6

Same name and namespace in other branches
  1. 7.2 includes/course.outline.inc \_course_outline_object_form()
  2. 7 includes/course.outline.inc \_course_outline_object_form()

Form constructor for a course object.

To be re-used in listing and creating new course objects.

1 call to _course_outline_object_form()
course_outline_overview_form in includes/course.outline.inc
Form constructor for course outline form.

File

includes/course.outline.inc, line 213
course_outline.inc

Code

function _course_outline_object_form($courseObject = NULL) {
  $rform['#tree'] = TRUE;
  $uniqid = $courseObject
    ->getId();
  foreach (array(
    'coid',
    'instance',
    'module',
    'object_type',
    'nid',
  ) as $key) {
    $rform[$key] = array(
      '#type' => 'value',
      '#default_value' => $courseObject
        ->getOption($key),
    );
  }

  // Do not use prefix/suffix because markup only renders with a value, and we
  // need the wrapper before the title is saved for ajax population after each
  // settings modal update.
  $title = $courseObject
    ->getTitle();
  $rform['title'] = array(
    '#prefix' => '<div id="title-' . $uniqid . '">',
    '#suffix' => '</div>',
    '#type' => 'markup',
    '#value' => check_plain($title ? $title : ' '),
  );
  $summary = $courseObject
    ->renderOptionsSummary();
  $rform['summary'] = array(
    '#prefix' => '<div id="summary-' . $uniqid . '">',
    '#suffix' => '</div>',
    '#type' => 'markup',
    '#value' => filter_xss_admin($summary ? $summary : ' '),
  );

  // Placeholder for the settings link, it gets added after this function runs
  // in course_outline_overview_form(). #value needs a space for the prefix and
  // suffix to render.
  // Settings link for saved objects.
  $text = t('Settings');
  $path = "node/{$courseObject->getCourseNid()}/course-object/nojs/{$uniqid}/options";
  $l_options = array(
    'query' => array(
      'destination' => "node/{$courseObject->getCourseNid()}/course-outline",
    ),
    'attributes' => array(
      'class' => 'ctools-use-modal',
    ),
  );
  $rform['options']['#value'] = l($text, $path, $l_options);
  $rform['weight'] = array(
    '#type' => 'weight',
    '#delta' => 50,
    '#default_value' => $courseObject
      ->getOption('weight'),
    '#attributes' => array(
      'class' => 'course-object-weight',
    ),
  );
  $rform['dummy'] = array(
    '#type' => 'checkbox',
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'dummy' => 1,
    ),
  );
  return $rform;
}