[ticket/289] Add method for generating select boxes in modules

This commit is contained in:
Marc Alexander
2014-07-24 13:16:48 +02:00
parent 53a58f8a7c
commit 240168e925
4 changed files with 76 additions and 11 deletions

View File

@@ -47,4 +47,28 @@ class modules_helper
return $disallow_access;
}
/**
* Generate select box
*
* @param string $key Key of select box
* @param array $select_ary Array of select box options
* @param array $selected_options Array of selected options
* @param string $select_key Key inside select box options
* that holds the option value
* @return string HTML code of select box
* @access public
*/
public function generate_select_box($key, $select_ary, $selected_options)
{
// Build options
$options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($select_ary as $id => $option)
{
$options .= '<option value="' . $option['value'] . '"' . ((in_array($option['value'], $selected_options)) ? ' selected="selected"' : '') . '>' . $option['title'] . '</option>';
}
$options .= '</select>';
return $options;
}
}