Page MenuHomePhabricator

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


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

Huji created this task.Dec 22 2016, 12:35 AM

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

Huji added a comment.Dec 22 2016, 12:41 AM

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:

Huji added a subscriber: matmarex.Dec 22 2016, 9:47 PM

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

Volker_E edited projects, added OOUI; removed Patch-For-Review.Feb 6 2017, 9:42 PM
Volker_E removed a subscriber: gerritbot.
Huji closed this task as Resolved.Feb 7 2017, 1:14 AM
Volker_E moved this task from Backlog to OOjs-UI-0.19.1 on the OOUI board.Feb 7 2017, 2:01 AM
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.
Aklapper removed a subscriber: Anomie.Oct 16 2020, 5:43 PM