MediaWiki REL1_35
HTMLComboboxField.php
Go to the documentation of this file.
1<?php
2
20 // FIXME Ewww, this shouldn't be adding any attributes not requested in $list :(
21 public function getAttributes( array $list ) {
22 $attribs = [
23 'type' => 'text',
24 'list' => $this->mName . '-datalist',
25 ] + parent::getAttributes( $list );
26
27 return $attribs;
28 }
29
30 public function getInputHTML( $value ) {
31 $datalist = new XmlSelect( false, $this->mName . '-datalist' );
32 $datalist->setTagName( 'datalist' );
33 $datalist->addOptions( $this->getOptions() );
34
35 return parent::getInputHTML( $value ) . $datalist->getHTML();
36 }
37
38 public function getInputOOUI( $value ) {
39 $disabled = false;
40 $allowedParams = [ 'tabindex' ];
41 $attribs = OOUI\Element::configFromHtmlAttributes(
42 $this->getAttributes( $allowedParams )
43 );
44
45 if ( $this->mClass !== '' ) {
46 $attribs['classes'] = [ $this->mClass ];
47 }
48
49 if ( !empty( $this->mParams['disabled'] ) ) {
50 $disabled = true;
51 }
52
53 return new OOUI\ComboBoxInputWidget( [
54 'name' => $this->mName,
55 'id' => $this->mID,
56 'options' => $this->getOptionsOOUI(),
57 'value' => strval( $value ),
58 'disabled' => $disabled,
59 ] + $attribs );
60 }
61
62 protected function shouldInfuseOOUI() {
63 return true;
64 }
65}
A combo box field.
shouldInfuseOOUI()
Whether the field should be automatically infused.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
getAttributes(array $list)
Returns the given attributes from the parameters Stable to override.
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