MediaWiki  REL1_23
HTMLSelectField.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class HTMLSelectField extends HTMLFormField {
00007     function validate( $value, $alldata ) {
00008         $p = parent::validate( $value, $alldata );
00009 
00010         if ( $p !== true ) {
00011             return $p;
00012         }
00013 
00014         $validOptions = HTMLFormField::flattenOptions( $this->getOptions() );
00015 
00016         if ( in_array( strval( $value ), $validOptions, true ) ) {
00017             return true;
00018         } else {
00019             return $this->msg( 'htmlform-select-badoption' )->parse();
00020         }
00021     }
00022 
00023     function getInputHTML( $value ) {
00024         $select = new XmlSelect( $this->mName, $this->mID, strval( $value ) );
00025 
00026         if ( !empty( $this->mParams['disabled'] ) ) {
00027             $select->setAttribute( 'disabled', 'disabled' );
00028         }
00029 
00030         if ( isset( $this->mParams['tabindex'] ) ) {
00031             $select->setAttribute( 'tabindex', $this->mParams['tabindex'] );
00032         }
00033 
00034         if ( $this->mClass !== '' ) {
00035             $select->setAttribute( 'class', $this->mClass );
00036         }
00037 
00038         $select->addOptions( $this->getOptions() );
00039 
00040         return $select->getHTML();
00041     }
00042 }