MediaWiki master
HTMLOrderedMultiselectField.php
Go to the documentation of this file.
1<?php
2
4
7
20
22 protected function getInputWidget( $params ) {
23 $widget = new OrderedMultiselectWidget( $params + [
24 'options' => $this->getOptionsOOUI(),
25 ] );
26 $widget->setAttributes( [ 'data-mw-modules' => implode( ',', $this->getOOUIModules() ) ] );
27 return $widget;
28 }
29
31 public function validate( $value, $alldata ) {
32 $this->mParams['allowedValues'] = self::flattenOptions( $this->getOptions() );
33 return parent::validate( $value, $alldata );
34 }
35
37 public function getOptionsOOUI() {
38 $optionsOouiSections = [];
39 $options = $this->getOptions();
40
41 foreach ( $options as $label => $section ) {
42 if ( is_array( $section ) ) {
43 $optionsOouiSections[ $label ] = Html::listDropdownOptionsOoui( $section );
44 unset( $options[$label] );
45 }
46 }
47
48 // If anything remains in the array, they are sectionless options. Put them at the beginning.
49 if ( $options ) {
50 $optionsOouiSections = array_merge(
51 [ '' => Html::listDropdownOptionsOoui( $options ) ],
52 $optionsOouiSections
53 );
54 }
55
56 return $optionsOouiSections;
57 }
58
60 public function getOOUIModules() {
61 return [ 'mediawiki.widgets.OrderedMultiselectWidget' ];
62 }
63}
Implements a tag multiselect input field with a searchable dropdown containing valid tags.
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.Don't forget to call pare...
getOptionsOOUI()
Get options and make them into arrays suitable for OOUI.to override array|null Options for inclusion ...
Implements a tag multiselect input field for arbitrary values.
static flattenOptions( $options)
flatten an array of options to a single array, for instance, a set of "<options>" inside "<optgroups>...
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
Widget to select multiple options from a dropdown.