function course_object_options_form in Course 7.2
Same name and namespace in other branches
- 6 course.module \course_object_options_form()
- 7 course.module \course_object_options_form()
Form API builder for course object options.
Parameters
array $form_state: Form state.
courseObject $courseObject: An initialized courseObject object.
Return value
array The FAPI array.
See also
course_object_options_form_validate()
course_object_options_form_submit()
1 string reference to 'course_object_options_form'
- course_object_options in ./
course.module - Page callback: Handles object options form for both ctools modal and nojs.
File
- ./
course.module, line 525 - course.module Core functionality for Courses.
Code
function course_object_options_form($form, &$form_state, $courseObject) {
$form = array();
$form[$courseObject
->getComponent()] = array(
'#title' => $courseObject
->getComponentName(),
'#type' => 'fieldset',
'#group' => 'course_tabs',
'#description' => t('Configuration for !name course objects.', array(
'!name' => $courseObject
->getComponentName(),
)),
'#weight' => 2,
);
$courseObject
->optionsForm($form, $form_state);
field_attach_form('course_object', (object) $courseObject
->getOptions(), $form, $form_state);
foreach (element_children($form) as $key) {
$element = $form[$key];
if (!empty($element['#type']) && $element['#type'] == 'container') {
$form['title'][$key] = $element;
unset($form[$key]);
}
}
$fieldset_key = $courseObject
->getComponent();
foreach (element_children($form) as $key) {
$element = $form[$key];
// @todo I want to catch all object-provided fields and group them into a
// fieldset. I should probably do this with an OO design change so that we
// know where the fields are coming from. Consider adding a
// CourseObject::objectOptionsForm which will separate object-specific
// behavior from Course-specific behavior.
if (!empty($element['#type']) && !in_array($element['#type'], array(
'',
'hidden',
'submit',
'button',
'fieldset',
'vertical_tabs',
'value',
))) {
$form[$fieldset_key][$key] = $element;
unset($form[$key]);
}
}
return $form;
}