function my_object_select_tag($object, $method, $disabled, $options = array(), $default_value = null) { $options = _parse_attributes($options); $related_class = _get_option($options, 'related_class', false); if (false === $related_class && preg_match('/^get(.+?)Id$/', $method, $match)) { $related_class = $match[1]; } $peer_method = _get_option($options, 'peer_method'); $text_method = _get_option($options, 'text_method'); $select_options = _get_options_from_objects(sfContext::getInstance()->retrieveObjects($related_class, $peer_method), $text_method); if ($value = _get_option($options, 'include_custom')) { $select_options = array('' => $value) + $select_options; } else { if (_get_option($options, 'include_title')) { $select_options = array('' => '-- ' . _convert_method_to_name($method, $options) . ' --') + $select_options; } else { if (_get_option($options, 'include_blank')) { $select_options = array('' => '') + $select_options; } } } if (is_object($object)) { $value = _get_object_value($object, $method, $default_value); } else { $value = $object; } $option_tags = my_options_for_select($select_options, $value, $disabled, $options); return select_tag(_convert_method_to_name($method, $options), $option_tags, $options); }
<?php use_helper('Form', 'myHelper'); echo my_options_for_select($content, '', $disabled);
?> </label><br/> <?php echo select_tag('status', my_options_for_select(array('1' => __('_STUDENT_COURSE_STATUS_PLANNED_'), '9' => __('_STUDENT_COURSE_STATUS_CANCELLED_')), $student_course->getStatus(), $sf_user->getAttribute('usertype', null, 'bo') == 'lector' ? array('3', '4') : array()), array('include_blank' => false)); ?> <?php echo form_error('status'); ?> </td></tr> <tr><td valign="top"> <label><?php echo __('Subject accal'); ?> </label><br/> <?php echo select_tag('subject_accal_id', my_options_for_select($subject_accal_options, array($student_course->getSubjectAccalId()), $disabled_sa, array('include_blank' => false)), array('disabled' => $student_course->getId() != null, 'size' => count($subject_accal_options) > 10 ? 15 : 10)); echo form_error('academic_calendar_id'); ?> <?php echo form_error('subject_accal_id'); ?> <?php echo observe_field('academic_calendar_id', array('update' => 'subject_accal_id', 'url' => 'subject_accal_s/selectByAccal', 'with' => "'accal_id='+\$('academic_calendar_id').value+'&student_id=" . $student->getId() . "&student_course_id=" . $student_course->getId() . "'", 'before' => "showIndicator('subject_accal_id', 'barsmall_white');", 'complete' => "hideIndicator();")); ?> </td><td valign="top"> <label><?php echo __('Class group'); ?> </label><br/> <?php echo object_select_tag($student_course, 'getClassGroupId', array('related_class' => 'ClassGroup', 'include_blank' => false, 'peer_method' => 'doSelectOrdered', 'text_method' => 'toString', 'size' => 10, 'disabled' => $student_course->getId() != null, 'id' => 'class_group_id'));