diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-02-15 17:23:27 +0100 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-02-15 17:23:27 +0100 |
commit | eeb8f429f3a505770c8dcf81998b009ba9d884fd (patch) | |
tree | cbb544714f25c6622104ec20e8960801ad20e4e6 /inc/form.php | |
parent | f1f2f711ea957b8fa3c9b4982e63b1476208c4e2 (diff) | |
download | rpg-eeb8f429f3a505770c8dcf81998b009ba9d884fd.tar.gz rpg-eeb8f429f3a505770c8dcf81998b009ba9d884fd.tar.bz2 |
add disable options to form_makeListboxField. Disable out of range revisions
Diffstat (limited to 'inc/form.php')
-rw-r--r-- | inc/form.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/inc/form.php b/inc/form.php index 312c42b60..25c65bd55 100644 --- a/inc/form.php +++ b/inc/form.php @@ -565,10 +565,11 @@ function form_makeListboxField($name, $values, $selected='', $label=null, $id='' if (is_null($label)) $label = $name; $options = array(); reset($values); - if (is_null($selected) || $selected == '') + if (is_null($selected) || $selected == '') { $selected = array(); - elseif (!is_array($selected)) + } elseif (!is_array($selected)) { $selected = array($selected); + } // FIXME: php doesn't know the difference between a string and an integer if (is_string(key($values))) { foreach ($values as $val=>$text) { @@ -576,11 +577,13 @@ function form_makeListboxField($name, $values, $selected='', $label=null, $id='' } } else { foreach ($values as $val) { - if (is_array($val)) - @list($val,$text) = $val; - else + $disabled = false; + if (is_array($val)) { + @list($val,$text,$disabled) = $val; + } else { $text = null; - $options[] = array($val,$text,in_array($val,$selected)); + } + $options[] = array($val,$text,in_array($val,$selected),$disabled); } } $elem = array('_elem'=>'listboxfield', '_options'=>$options, '_text'=>$label, '_class'=>$class, @@ -934,11 +937,12 @@ function form_listboxfield($attrs) { $s .= '<select '.buildAttributes($attrs,true).'>'.DOKU_LF; if (!empty($attrs['_options'])) { foreach ($attrs['_options'] as $opt) { - @list($value,$text,$select) = $opt; + @list($value,$text,$select,$disabled) = $opt; $p = ''; if(is_null($text)) $text = $value; $p .= ' value="'.formText($value).'"'; if (!empty($select)) $p .= ' selected="selected"'; + if ($disabled) $p .= ' disabled="disabled"'; $s .= '<option'.$p.'>'.formText($text).'</option>'; } } else { |