Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php |
— | — | @@ -524,6 +524,7 @@ |
525 | 525 | } |
526 | 526 | |
527 | 527 | static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 528 | + // For backward compatibility with pre-SF-2.1 forms |
528 | 529 | if ( array_key_exists( 'no autocomplete', $other_args ) && |
529 | 530 | $other_args['no autocomplete'] == true ) { |
530 | 531 | unset( $other_args['autocompletion source'] ); |
— | — | @@ -565,24 +566,37 @@ |
566 | 567 | $values = SFUtils::getAutocompleteValues($autocompletion_source, $autocomplete_field_type ); |
567 | 568 | $autocompletion_source = str_replace( "'", "\'", $autocompletion_source ); |
568 | 569 | |
569 | | - $divClass = "ui-widget"; |
570 | | - if ($is_mandatory) { $divClass .= " mandatory"; } |
571 | | - $text =<<<END |
572 | | -<div class="$divClass"> |
573 | | - <select id="input_$sfgFieldNum" name="$input_name" class="$className" tabindex="$sfgTabIndex" autocompletesettings="$autocompletion_source" comboboxwidth="$pixel_width"> |
574 | | - <option value="$cur_value"></option> |
| 570 | + $optionsText = Xml::element( 'option', array( 'value' => $cur_value ), null, false ) . "\n"; |
| 571 | + foreach ( $values as $value ) { |
| 572 | + $optionsText .= Xml::element( 'option', array( 'value' => $value ), $value ) . "\n"; |
| 573 | + } |
575 | 574 | |
576 | | -END; |
577 | | - foreach ($values as $value) { |
578 | | - $text .= " <option value=\"$value\">$value</option>\n"; |
| 575 | + $selectAttrs = array( |
| 576 | + 'id' => "input_$sfgFieldNum", |
| 577 | + 'name' => $input_name, |
| 578 | + 'class' => $className, |
| 579 | + 'tabindex' => $sfgTabIndex, |
| 580 | + 'autocompletesettings' => $autocompletion_source, |
| 581 | + 'comboboxwidth' => $pixel_width, |
| 582 | + ); |
| 583 | + if ( array_key_exists( 'existing values only', $other_args ) ) { |
| 584 | + $selectAttrs['existingvaluesonly'] = 'true'; |
579 | 585 | } |
580 | | - $text .= <<<END |
581 | | - </select> |
582 | | -</div> |
583 | | -END; |
| 586 | + $selectText = Xml::tags( 'select', $selectAttrs, $optionsText ); |
584 | 587 | |
| 588 | + $divClass = "ui-widget"; |
| 589 | + if ($is_mandatory) { $divClass .= " mandatory"; } |
| 590 | + $text = Xml::tags( 'div', array( 'class' => $divClass ), $selectText ); |
585 | 591 | return $text; |
586 | 592 | } |
| 593 | + |
| 594 | + public static function getParameters() { |
| 595 | + $params = parent::getParameters(); |
| 596 | + $params[] = array( 'name' => 'size', 'type' => 'int', 'description' => wfMsg( 'sf_forminputs_size' ) ); |
| 597 | + $params = array_merge( $params, SFEnumInput::getValuesParameters() ); |
| 598 | + $params[] = array( 'name' => 'existing values only', 'type' => 'boolean', 'description' => wfMsg( 'sf_forminputs_existingvaluesonly' ) ); |
| 599 | + return $params; |
| 600 | + } |
587 | 601 | } |
588 | 602 | |
589 | 603 | class SFTextWithAutocompleteInput extends SFTextInput { |