Merge "API: Add show=unread to ApiQueryWatchlist"
[mediawiki.git] / includes / htmlform / HTMLSelectField.php
blobc32b445157ff2b1bb3caa88f2c3c69ddbf847edb
1 <?php
3 /**
4 * A select dropdown field. Basically a wrapper for Xmlselect class
5 */
6 class HTMLSelectField extends HTMLFormField {
7 function validate( $value, $alldata ) {
8 $p = parent::validate( $value, $alldata );
10 if ( $p !== true ) {
11 return $p;
14 $validOptions = HTMLFormField::flattenOptions( $this->getOptions() );
16 if ( in_array( strval( $value ), $validOptions, true ) ) {
17 return true;
18 } else {
19 return $this->msg( 'htmlform-select-badoption' )->parse();
23 function getInputHTML( $value ) {
24 $select = new XmlSelect( $this->mName, $this->mID, strval( $value ) );
26 if ( !empty( $this->mParams['disabled'] ) ) {
27 $select->setAttribute( 'disabled', 'disabled' );
30 if ( isset( $this->mParams['tabindex'] ) ) {
31 $select->setAttribute( 'tabindex', $this->mParams['tabindex'] );
34 if ( $this->mClass !== '' ) {
35 $select->setAttribute( 'class', $this->mClass );
38 $select->addOptions( $this->getOptions() );
40 return $select->getHTML();