MediaWiki master
HTMLComboboxField.php
Go to the documentation of this file.
1<?php
2
4
7
26 public function getAttributes( array $list ) {
27 // FIXME Ewww, this shouldn't be adding any attributes not requested in $list :(
28 $attribs = [
29 'type' => 'text',
30 'list' => $this->mName . '-datalist',
31 ] + parent::getAttributes( $list );
32
33 return $attribs;
34 }
35
37 public function getInputHTML( $value ) {
38 return parent::getInputHTML( $value ) .
39 Html::rawElement( 'datalist',
40 [ 'id' => $this->mName . '-datalist' ],
41 XmlSelect::formatOptions( $this->getOptions() )
42 );
43 }
44
46 public function getInputOOUI( $value ) {
47 $disabled = false;
48 $allowedParams = [ 'tabindex' ];
49 $attribs = \OOUI\Element::configFromHtmlAttributes(
50 $this->getAttributes( $allowedParams )
51 );
52
53 if ( $this->mClass !== '' ) {
54 $attribs['classes'] = [ $this->mClass ];
55 }
56
57 if ( !empty( $this->mParams['disabled'] ) ) {
58 $disabled = true;
59 }
60
61 if ( $this->mPlaceholder !== '' ) {
62 $attribs['placeholder'] = $this->mPlaceholder;
63 }
64
65 return new \OOUI\ComboBoxInputWidget( [
66 'name' => $this->mName,
67 'id' => $this->mID,
68 'options' => $this->getOptionsOOUI(),
69 'value' => strval( $value ),
70 'disabled' => $disabled,
71 ] + $attribs );
72 }
73
75 protected function shouldInfuseOOUI() {
76 return true;
77 }
78}
79
81class_alias( HTMLComboboxField::class, 'HTMLComboboxField' );
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
shouldInfuseOOUI()
Whether the field should be automatically infused.Note that all OOUI HTMLForm fields are infusable (y...
getAttributes(array $list)
Returns the given attributes from the parameters.to overridearray Attributes
getOptionsOOUI()
Get options and make them into arrays suitable for OOUI.
getOptions()
Fetch the array of options from the field's parameters.
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
Class for generating HTML <select> or <datalist> elements.
Definition XmlSelect.php:16