Skip to content
Snippets Groups Projects
Commit db4ca7bc authored by Thomas Hackl's avatar Thomas Hackl
Browse files

allow optional use of semester index in SemesterSelector, fixes #685

parent ddb7f1c9
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
<?= Semester::getSemesterSelector( <?= Semester::getSemesterSelector(
['name' => 'sem_select', 'id' => 'sem_select', 'class' => 'user_form'], ['name' => 'sem_select', 'id' => 'sem_select', 'class' => 'user_form'],
$sem_select, 'semester_id', $sem_select, 'semester_id',
true true,
false
)?> )?>
</label> </label>
<label> <label>
......
...@@ -233,13 +233,16 @@ class Semester extends SimpleORMap ...@@ -233,13 +233,16 @@ class Semester extends SimpleORMap
* @param integer $default * @param integer $default
* @param string $option_value * @param string $option_value
* @param boolean $include_all * @param boolean $include_all
* @param boolean $use_semester_id
* @return string * @return string
*/ */
public static function getSemesterSelector( public static function getSemesterSelector(
$select_attributes = null, $select_attributes = null,
$default = 0, $default = 0,
$option_value = 'semester_id', $option_value = 'semester_id',
$include_all = true) $include_all = true,
$use_semester_id = true
)
{ {
$semester = Semester::findAllVisible(); $semester = Semester::findAllVisible();
...@@ -262,6 +265,7 @@ class Semester extends SimpleORMap ...@@ -262,6 +265,7 @@ class Semester extends SimpleORMap
$template->select_attributes = $select_attributes; $template->select_attributes = $select_attributes;
$template->default = $default; $template->default = $default;
$template->option_value = $option_value; $template->option_value = $option_value;
$template->use_semester_id = $use_semester_id;
return $template->render(); return $template->render();
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<select <?= $attributes ?>> <select <?= $attributes ?>>
<? foreach ($semesters as $sem_key => $one_sem) : ?> <? foreach ($semesters as $sem_key => $one_sem) : ?>
<? $one_sem['key'] = $sem_key; ?> <? $one_sem['key'] = $sem_key; ?>
<option value="<?= $one_sem[$option_value] ?>" <?= ($one_sem[$option_value] == $default ? "selected" : "") ?>> <option value="<?= $use_semester_id ? $one_sem[$option_value] : $sem_key ?>" <?= ($one_sem[$option_value] == $default ? "selected" : "") ?>>
<?= htmlReady($one_sem['name']) ?> <?= htmlReady($one_sem['name']) ?>
</option> </option>
<? endforeach ?> <? endforeach ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment