MediaWiki REL1_31
HTMLComboboxField.php
Go to the documentation of this file.
1<?php
2
18 // FIXME Ewww, this shouldn't be adding any attributes not requested in $list :(
19 public function getAttributes( array $list ) {
20 $attribs = [
21 'type' => 'text',
22 'list' => $this->mName . '-datalist',
23 ] + parent::getAttributes( $list );
24
25 return $attribs;
26 }
27
28 public function getInputHTML( $value ) {
29 $datalist = new XmlSelect( false, $this->mName . '-datalist' );
30 $datalist->setTagName( 'datalist' );
31 $datalist->addOptions( $this->getOptions() );
32
33 return parent::getInputHTML( $value ) . $datalist->getHTML();
34 }
35
36 public function getInputOOUI( $value ) {
37 $disabled = false;
38 $allowedParams = [ 'tabindex' ];
39 $attribs = OOUI\Element::configFromHtmlAttributes(
40 $this->getAttributes( $allowedParams )
41 );
42
43 if ( $this->mClass !== '' ) {
44 $attribs['classes'] = [ $this->mClass ];
45 }
46
47 if ( !empty( $this->mParams['disabled'] ) ) {
48 $disabled = true;
49 }
50
51 return new OOUI\ComboBoxInputWidget( [
52 'name' => $this->mName,
53 'id' => $this->mID,
54 'options' => $this->getOptionsOOUI(),
55 'value' => strval( $value ),
56 'disabled' => $disabled,
57 ] + $attribs );
58 }
59
60 protected function shouldInfuseOOUI() {
61 return true;
62 }
63}
A combo box field.
shouldInfuseOOUI()
Whether the field should be automatically infused.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
getAttributes(array $list)
Returns the given attributes from the parameters.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
getOptions()
Fetch the array of options from the field's parameters.
getOptionsOOUI()
Get options and make them into arrays suitable for OOUI.
<input> field.
Class for generating HTML <select> or <datalist> elements.
Definition XmlSelect.php:26
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:2014