Skip to content
Browse files

MDL-29394 form editor - Use hidden field when only 1 format option is…

… available #947
  • Loading branch information...
1 parent 3eabe0c commit 5a1a7112cdc824b0c52532ee37ec743098830ab4 Colin Chambers committed with stronk7 Sep 19, 2011
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/form/editor.php
View
10 lib/form/editor.php
@@ -237,12 +237,12 @@ function toHtml() {
$str .= '</textarea></div>';
$str .= '<div>';
- $str .= '<select name="'.$elname.'[format]">';
- foreach ($formats as $key=>$desc) {
- $selected = ($format == $key) ? 'selected="selected"' : '';
- $str .= '<option value="'.s($key).'" '.$selected.'>'.$desc.'</option>';
+ if (count($formats)>1) {
+ $str.= html_writer::select($formats, $elname.'[format]', $format, false);
+ } else {
+ $str.= html_writer::empty_tag('input',
+ array('name'=>$elname.'[format]', 'type'=> 'hidden', 'value' => array_pop(array_keys($formats))));
}
- $str .= '</select>';
$str .= '</div>';
// during moodle installation, user area doesn't exist

0 comments on commit 5a1a711

Please sign in to comment.
Something went wrong with that request. Please try again.