MediaWiki  1.23.13
HTMLSelectField.php
Go to the documentation of this file.
1 <?php
2 
7  function validate( $value, $alldata ) {
8  $p = parent::validate( $value, $alldata );
9 
10  if ( $p !== true ) {
11  return $p;
12  }
13 
14  $validOptions = HTMLFormField::flattenOptions( $this->getOptions() );
15 
16  if ( in_array( strval( $value ), $validOptions, true ) ) {
17  return true;
18  } else {
19  return $this->msg( 'htmlform-select-badoption' )->parse();
20  }
21  }
22 
23  function getInputHTML( $value ) {
24  $select = new XmlSelect( $this->mName, $this->mID, strval( $value ) );
25 
26  if ( !empty( $this->mParams['disabled'] ) ) {
27  $select->setAttribute( 'disabled', 'disabled' );
28  }
29 
30  if ( isset( $this->mParams['tabindex'] ) ) {
31  $select->setAttribute( 'tabindex', $this->mParams['tabindex'] );
32  }
33 
34  if ( $this->mClass !== '' ) {
35  $select->setAttribute( 'class', $this->mClass );
36  }
37 
38  $select->addOptions( $this->getOptions() );
39 
40  return $select->getHTML();
41  }
42 }
HTMLFormField\getOptions
getOptions()
Fetch the array of options from the field's parameters.
Definition: HTMLFormField.php:550
HTMLSelectField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
Definition: HTMLSelectField.php:23
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
XmlSelect
Definition: Xml.php:844
HTMLSelectField
A select dropdown field.
Definition: HTMLSelectField.php:6
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:7
$value
$value
Definition: styleTest.css.php:45
HTMLFormField\msg
msg()
Get a translated interface message.
Definition: HTMLFormField.php:51
HTMLSelectField\validate
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.
Definition: HTMLSelectField.php:7
HTMLFormField\flattenOptions
static flattenOptions( $options)
flatten an array of options to a single array, for instance, a set of "<options>" inside "<optgroups>...
Definition: HTMLFormField.php:601