diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
commit | c9aa36da061816dee256a979c2ff8d2ee41824d9 (patch) | |
tree | 29f7002b80ee984b488bd047dbbd80b36bf892e9 /includes/htmlform/HTMLSelectField.php | |
parent | b4274e0e33eafb5e9ead9d949ebf031a9fb8363b (diff) | |
parent | d1ba966140d7a60cd5ae4e8667ceb27c1a138592 (diff) |
Merge branch 'archwiki'
# Conflicts:
# skins/ArchLinux.php
# skins/ArchLinux/archlogo.gif
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(); + } +} |