Permalink
Browse files

Merge commit '3f07e4160aafe5c0e90f65e097e6a83427a9f86c' into drop

  • Loading branch information...
2 parents 2a934c7 + 3f07e41 commit bdaffa474682672ed052b56d4bffb8b750613326 ben hengst committed Dec 1, 2011
Showing with 12 additions and 5 deletions.
  1. +12 −5 system/helpers/form_helper.php
View
17 system/helpers/form_helper.php
@@ -309,16 +309,23 @@ function form_multiselect($name = '', $options = array(), $selected = array(), $
* Drop-down Menu
*
* @access public
- * @param string
+ * @param mixed
* @param array
* @param string
* @param string
* @return string
*/
if ( ! function_exists('form_dropdown'))
{
- function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
+ function form_dropdown($data = '', $options = array(), $selected = array(), $extra = '')
{
+ if ( ! is_array($data))
+ {
+ $data = array('name' => $data);
+ }
+
+ $defaults = array('name' => $data['name']);
+
if ( ! is_array($selected))
{
$selected = array($selected);
@@ -328,17 +335,17 @@ function form_dropdown($name = '', $options = array(), $selected = array(), $ext
if (count($selected) === 0)
{
// If the form name appears in the $_POST array we have a winner!
- if (isset($_POST[$name]))
+ if (isset($_POST[$data['name']]))
{
- $selected = array($_POST[$name]);
+ $selected = array($_POST[$data['name']]);
}
}
if ($extra != '') $extra = ' '.$extra;
$multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
- $form = '<select name="'.$name.'"'.$extra.$multiple.">\n";
+ $form = '<select '._parse_form_attributes($data, $defaults).$extra.$multiple.">\n";
foreach ($options as $key => $val)
{

0 comments on commit bdaffa4

Please sign in to comment.