Page MenuHomePhabricator

OOjs UI should allow disabling specific options of CheckboxMultiselectInputWidget
Closed, ResolvedPublic

Description

For widgets that contain multiple child widget (e.g. CheckboxMultiselectInputWidget), this would allow the user to specify which of the options are disabled.

Currently, because no array is supported, disabled is always treated as binary, i.e. if it is non-null, the entire CheckboxMultiselectInputWidget will be disabled. This prevents issues like T153751 to be solved.

Event Timeline

Change 328601 had a related patch set uploaded (by Huji):
OOjs UI should allow disabled to contain an array

https://gerrit.wikimedia.org/r/328601

Using the patch above and code like this:

			'grants' => [
				'type' => 'multiselect',
				'options' => [ 'Alphas' => 'alpha', 'Bravos' => 'bravo', 'Charlies' => 'charlie' ],
				'default' => [ 'bravo', 'charlie' ],
				'disabled' => [ 'bravo' ],
			],

I get this output:

Capture.PNG (214×165 px, 5 KB)

An alternative approach was proposed by @matmarex which would look like this:

new OOUI\CheckboxMultiselectInputWidget( [
				'value' => [ 'dog', 'cat' ],
				'options' => [
					[
						'data' => 'cat',
						'label' => 'Cat'
					],
					[
						'disabled' => true,
						'label' => 'Dog'
					],
					[
						'data' => 'goldfish',
						'label' => 'Goldfish'
					],
				]
			] )

However, that is not backward compatible (the options parameter is currently an associative array of type key => value and this approach will replace it with a non-associative array of associative arrays [key => val], [key => val]. Besides, the method I proposed is consistent with how the default option works (you just specify which options should be checked by default, and with my patch you also specify which options should be disabled).

So I am going to stick to my approach.

Change 328601 merged by jenkins-bot:
CheckboxMultiselectInputWidget: Allow disabling specific options

https://gerrit.wikimedia.org/r/328601

Volker_E edited projects, added OOUI (OOjs-UI-0.19.1); removed OOUI.
matmarex renamed this task from OOjs UI should allow `disabled` to contain an array to OOjs UI should allow disabling specific options of CheckboxMultiselectInputWidget.Feb 7 2017, 3:40 PM
matmarex removed a project: MediaWiki-HTMLForm.