- Added/removed spaces around parenthesis - Added space after switch/if/foreach - changed else if to elseif Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* A select dropdown field. Basically a wrapper for Xmlselect class
|
|
*/
|
|
class HTMLSelectField extends HTMLFormField {
|
|
function validate( $value, $alldata ) {
|
|
$p = parent::validate( $value, $alldata );
|
|
|
|
if ( $p !== true ) {
|
|
return $p;
|
|
}
|
|
|
|
$validOptions = HTMLFormField::flattenOptions( $this->getOptions() );
|
|
|
|
if ( in_array( strval( $value ), $validOptions, true ) ) {
|
|
return true;
|
|
} else {
|
|
return $this->msg( 'htmlform-select-badoption' )->parse();
|
|
}
|
|
}
|
|
|
|
function getInputHTML( $value ) {
|
|
$select = new XmlSelect( $this->mName, $this->mID, strval( $value ) );
|
|
|
|
if ( !empty( $this->mParams['disabled'] ) ) {
|
|
$select->setAttribute( 'disabled', 'disabled' );
|
|
}
|
|
|
|
$allowedParams = array( 'tabindex', 'size' );
|
|
$customParams = $this->getAttributes( $allowedParams );
|
|
foreach ( $customParams as $name => $value ) {
|
|
$select->setAttribute( $name, $value );
|
|
}
|
|
|
|
if ( $this->mClass !== '' ) {
|
|
$select->setAttribute( 'class', $this->mClass );
|
|
}
|
|
|
|
$select->addOptions( $this->getOptions() );
|
|
|
|
return $select->getHTML();
|
|
}
|
|
}
|