Page MenuHomePhabricator

Allow MenuTagMultiSelectWidget to be used in HTMLForm with value represented as a textarea
Closed, ResolvedPublic

Description

For T31398, we need a form field type that allows multiple selections and has a searchable dropdown of valid values. While HTMLMultiSelectField does all of that, it's backed by a list of html checkboxes, and so doesn't preserve the order of selected values. Order is important for the list of pages in a gadget as it defines the sequence in which JS sources are concatenated, and in case of packaged gadgets the first selected page is used as the entry point.

The newly added MenuTagMultiselectWidget (in T380995, cc @Func @Daimona) also uses checkbox list, deviating from the behaviour of the parent class TagMultiselectWidget which uses a textarea (value represented as a newline-delimited string).

Approach 1
  • Implement a parameter in MenuTagMutliselectWidget so that it can be backed by either a checkbox list or a textarea.
  • Add a HTMLMenuTagMultiSelectField class which uses MenuTagMutliselectWidget with that parameter set.
  • Enable use of type => 'menutagmultiselect' in HTMLForm fields.
Approach 2
  • Switch MenuTagMultiselectWidget to always use a textarea.
  • Fix HTMLMultiSelectField loadDataFromRequest() accordingly.

Event Timeline

SD0001 renamed this task from Allow MenuTagMultiSelectWidget to be used in HTMLForm to Allow MenuTagMultiSelectWidget to be used with value represented as a textarea in HTMLForm .Jan 4 2025, 7:44 PM

Change #1108173 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/core@master] htmlform: Add HTMLMenuTagMultiselectField for use in HTMLForm

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

SD0001 renamed this task from Allow MenuTagMultiSelectWidget to be used with value represented as a textarea in HTMLForm to Allow MenuTagMultiSelectWidget to be used in HTMLForm with value represented as a textarea .Jan 6 2025, 10:19 PM
SD0001 updated the task description. (Show Details)

The above patch implements Approach 1. Now, I think the Approach 2 (see patch below) is better as it doesn't involve having MenuTagMultiselectWidget operate in two different modes based on a parameter, which feels like added complexity and tech debt.

Change #1108497 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/core@master] htmlform: Switch MenuTagMultiselectWidget to be backed by a textarea

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

Change #1108666 had a related patch set uploaded (by Func; author: Func):

[mediawiki/core@master] HTMLMultiSelectField: Keep the order of the selected options

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

Change #1108173 merged by jenkins-bot:

[mediawiki/core@master] htmlform: Add HTMLOrderedMultiselectField for use in HTMLForm

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

matmarex assigned this task to SD0001.

Change #1108666 abandoned by Func:

[mediawiki/core@master] HTMLMultiSelectField: Keep the order of the selected options

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

Change #1108497 abandoned by SD0001:

[mediawiki/core@master] htmlform: Switch MenuTagMultiselectWidget to be backed by a textarea

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