Commit 8367d662 authored by Kjartan's avatar Kjartan

Changes

- Modifed form_select() to accept an optional 6th parameter which is appeneded
  to the select tag. $value can now also be an array. This allows for multiple
  selects:
  form_select($header, $name, $values, $options, $help, "multiple=\"true\" size=\"10\"");
- Updated account.module to use the extended form_select() functionality.
parent 542b60a1
...@@ -179,10 +179,10 @@ function form_textarea($title, $name, $value, $cols, $rows, $description = 0) { ...@@ -179,10 +179,10 @@ function form_textarea($title, $name, $value, $cols, $rows, $description = 0) {
return form_item($title, "<textarea wrap=\"virtual\" cols=\"$cols\" rows=\"$rows\" name=\"edit[$name]\">". check_form($value) ."</textarea>", $description); return form_item($title, "<textarea wrap=\"virtual\" cols=\"$cols\" rows=\"$rows\" name=\"edit[$name]\">". check_form($value) ."</textarea>", $description);
} }
function form_select($title, $name, $value, $options, $description = 0) { function form_select($title, $name, $value, $options, $description = 0, $extra = 0) {
if (count($options) > 0) { if (count($options) > 0) {
foreach ($options as $key=>$choice) $select .= "<option value=\"$key\"". ($key == $value ? " selected" : "") .">". check_form($choice) ."</option>"; foreach ($options as $key=>$choice) $select .= "<option value=\"$key\"". (is_array($value) ? (in_array($key, $value) ? " selected" : "") : ($key == $value ? " selected" : "")) .">". check_form($choice) ."</option>";
return form_item($title, "<select name=\"edit[$name]\">$select</select>", $description); return form_item($title, "<select name=\"edit[$name]\"". ($extra ? " $extra" : "") .">$select</select>", $description);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment