diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /includes/htmlform/HTMLSelectField.php | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/htmlform/HTMLSelectField.php')
-rw-r--r-- | includes/htmlform/HTMLSelectField.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/includes/htmlform/HTMLSelectField.php b/includes/htmlform/HTMLSelectField.php new file mode 100644 index 00000000..a198037a --- /dev/null +++ b/includes/htmlform/HTMLSelectField.php @@ -0,0 +1,44 @@ +<?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(); + } +} |