9d719f640c0935bd53ed9394c8c4188e1cfd7847
4 * A select dropdown field. Basically a wrapper for Xmlselect class
6 class HTMLSelectField
extends HTMLFormField
{
7 function validate( $value, $alldata ) {
8 $p = parent
::validate( $value, $alldata );
14 $validOptions = HTMLFormField
::flattenOptions( $this->mParams
['options'] );
16 if ( in_array( $value, $validOptions ) ) {
19 return $this->msg( 'htmlform-select-badoption' )->parse();
23 function getInputHTML( $value ) {
24 $select = new XmlSelect( $this->mName
, $this->mID
, strval( $value ) );
26 # If one of the options' 'name' is int(0), it is automatically selected.
27 # because PHP sucks and thinks int(0) == 'some string'.
28 # Working around this by forcing all of them to strings.
29 foreach ( $this->mParams
['options'] as &$opt ) {
30 if ( is_int( $opt ) ) {
31 $opt = strval( $opt );
34 unset( $opt ); # PHP keeps $opt around as a reference, which is a bit scary
36 if ( !empty( $this->mParams
['disabled'] ) ) {
37 $select->setAttribute( 'disabled', 'disabled' );
40 if ( isset( $this->mParams
['tabindex'] ) ) {
41 $select->setAttribute( 'tabindex', $this->mParams
['tabindex'] );
44 if ( $this->mClass
!== '' ) {
45 $select->setAttribute( 'class', $this->mClass
);
48 $select->addOptions( $this->mParams
['options'] );
50 return $select->getHTML();