Page MenuHomePhabricator

Mapping template not consistently invoked for tokens input type
Closed, ResolvedPublic

Description

I found some issues when I want to use a mapping template with a field of the "tokens" input type. I have a template to turn BCP 47 language tags into English language names.

{{{field|language|values=en, es, de, fr|input type=tokens|mapping template=BCP47}}}

Values from properties do not map
I am forced to hardcode the |values= instead of |property=Language code

Does not map if loaded with two or more tokens
If a user starts with a blank form and picks "English" and saves, "en" is put in the |language paramter. When they view the edit form again, "English" prepopulates the language as expected. This applies to "Preview" and "Show changes", too.

But if they pick "English" and "Spanish". Before they've saved or previewed, it behaves normally, but if they save or preview, "en" and "es" prepopulate the language field instead, and even weirder is, "en" and "es" get added to the token dropdown while "English" and "Spanish" remain as options.

Event Timeline

Change #1271767 had a related patch set uploaded (by Dumbledore; author: Dumbledore):

[mediawiki/extensions/PageForms@master] PF_TokensInput: Pass mapping args as HTML attributes

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

Change #1271767 merged by jenkins-bot:

[mediawiki/extensions/PageForms@master] PF_TokensInput: Pass mapping args as HTML attributes

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

Change #1275472 had a related patch set uploaded (by Dumbledore; author: Dumbledore):

[mediawiki/extensions/PageForms@master] Fix tokens mapping in HTML DOM and API endpoint

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

Change #1275472 had a related patch set uploaded (by Pppery; author: Dumbledore):

[mediawiki/extensions/PageForms@master] Fix tokens mapping in HTML DOM and API endpoint

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

Change #1275472 had a related patch set uploaded (by Pppery; author: Dumbledore):

[mediawiki/extensions/PageForms@master] Fix tokens mapping in HTML DOM and API endpoint

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

Change #1276414 had a related patch set uploaded (by Dumbledore; author: Dumbledore):

[mediawiki/extensions/PageForms@master] Fix tokens mapping during form load and autocomplete

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

Change #1275472 merged by jenkins-bot:

[mediawiki/extensions/PageForms@master] Fix tokens mapping in HTML DOM and API endpoint

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

Change #1276414 merged by jenkins-bot:

[mediawiki/extensions/PageForms@master] Fix tokens mapping during form load and autocomplete

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

Yaron_Koren subscribed.

I believe this is fixed now! Though feel free to re-open if there are still any problem with tokens mapping.

@Dumbledore - thank you for your fantastic work on this!