From 9b106e85fe5ef8e4ebf7a3bd0d0bd48a8a4fe717 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Wed, 5 May 2004 15:58:26 +0000 Subject: Adding support for through form_select. See the PHPdoc for usage. --- includes/common.inc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index 2e2cf12d7..d4e8d6b45 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1050,10 +1050,32 @@ function form_textarea($title, $name, $value, $cols, $rows, $description = NULL, return theme("form_element", $title, "", $description, $name, $required); } +/** + * Outputs a form select item. + * + * @param $options Array containing the options to choose from. The basic format + * is "value" => "label". If you want to group options together + * (with tags), the format becomes "group name" => + * $options, where $options is an array of "value" => "label" + * pairs. + * + * Examples: + * @verbatim $flavor = array(1 => "Vanilla", 2 => "Chocolate", 3 => "Strawberry"); @endverbatim + * @verbatim $order = array("Food" => array(1 => "Ice cream", 2 => "Hamburger"), "Drink" => array(1 => "Cola", 2 => "Water")); @endverbatim + */ function form_select($title, $name, $value, $options, $description = NULL, $extra = 0, $multiple = 0, $required = FALSE) { $select = ''; foreach ($options as $key => $choice) { - $select .= ""; + if (is_array($choice)) { + $select .= ""; + foreach ($choice as $key => $choice) { + $select .= ""; + } + $select .= ""; + } + else { + $select .= ""; + } } return theme("form_element", $title, "", $description, $name, $required); } -- cgit v1.2.3