Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427045
HTMLComboboxField.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
HTMLComboboxField.php
View Options
<?php
namespace
MediaWiki\HTMLForm\Field
;
use
MediaWiki\Xml\XmlSelect
;
/**
* A combo box field.
*
* You can think of it as a dropdown select with the ability to add custom options,
* or as a text field with input suggestions (autocompletion).
*
* When JavaScript is not supported or enabled, it uses HTML5 `<datalist>` element.
*
* Besides the parameters recognized by HTMLTextField, the following are
* recognized:
* options-messages - As for HTMLSelectField
* options - As for HTMLSelectField
* options-message - As for HTMLSelectField
*
* @stable to extend
*/
class
HTMLComboboxField
extends
HTMLTextField
{
// FIXME Ewww, this shouldn't be adding any attributes not requested in $list :(
public
function
getAttributes
(
array
$list
)
{
$attribs
=
[
'type'
=>
'text'
,
'list'
=>
$this
->
mName
.
'-datalist'
,
]
+
parent
::
getAttributes
(
$list
);
return
$attribs
;
}
public
function
getInputHTML
(
$value
)
{
$datalist
=
new
XmlSelect
(
false
,
$this
->
mName
.
'-datalist'
);
$datalist
->
setTagName
(
'datalist'
);
$datalist
->
addOptions
(
$this
->
getOptions
()
);
return
parent
::
getInputHTML
(
$value
)
.
$datalist
->
getHTML
();
}
public
function
getInputOOUI
(
$value
)
{
$disabled
=
false
;
$allowedParams
=
[
'tabindex'
];
$attribs
=
\OOUI\Element
::
configFromHtmlAttributes
(
$this
->
getAttributes
(
$allowedParams
)
);
if
(
$this
->
mClass
!==
''
)
{
$attribs
[
'classes'
]
=
[
$this
->
mClass
];
}
if
(
!
empty
(
$this
->
mParams
[
'disabled'
]
)
)
{
$disabled
=
true
;
}
if
(
$this
->
mPlaceholder
!==
''
)
{
$attribs
[
'placeholder'
]
=
$this
->
mPlaceholder
;
}
return
new
\OOUI\ComboBoxInputWidget
(
[
'name'
=>
$this
->
mName
,
'id'
=>
$this
->
mID
,
'options'
=>
$this
->
getOptionsOOUI
(),
'value'
=>
strval
(
$value
),
'disabled'
=>
$disabled
,
]
+
$attribs
);
}
protected
function
shouldInfuseOOUI
()
{
return
true
;
}
}
/** @deprecated class alias since 1.42 */
class_alias
(
HTMLComboboxField
::
class
,
'HTMLComboboxField'
);
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 14:07 (1 d, 17 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
30/b6/a42e987ba62300c83b45e716545d
Default Alt Text
HTMLComboboxField.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment