You are here

function _course_outline_object_form in Course 7

Same name and namespace in other branches
  1. 6 includes/course.outline.inc \_course_outline_object_form()
  2. 7.2 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 222
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',
    '#markup' => check_plain($title ? $title : ' '),
  );
  $summary = $courseObject
    ->renderOptionsSummary();
  $rform['summary'] = array(
    '#prefix' => '<div id="summary-' . $uniqid . '">',
    '#suffix' => '</div>',
    '#type' => 'markup',
    '#markup' => 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",
    ),
  );
  $rform['options']['#markup'] = l($text, $path, $l_options);
  $rform['weight'] = array(
    '#type' => 'textfield',
    '#size' => 3,
    '#default_value' => $courseObject
      ->getOption('weight'),
    '#attributes' => array(
      'class' => array(
        'course-object-weight',
      ),
    ),
  );
  return $rform;
}