Extension talk:Page Forms

Date input type struggles with fragmentary dates
Hello again. I'm still using Mediawiki 1.30.0 with the page forms extension 4.3.1 on a Synology NAS. This system is still not public. Cargo or Semantic Mediawiki is still not installed. The PHP version is still 5.6.34 and MariaDB 10.0.32 serves still as database.

Now I created a form using the combox field:. Three input field are diplayed. One for the day, the next for the month and the last for the year. If I enter a full scale date with day, month and year, all is fine. If I enter only a day or only a month and if I save the article, the input has been dumped. The template call in the article shows no Day of birth parameter. So far, so good. If I enter a year only, the articles template call shows this year at the Day of birth parameter. And if I want to edit this article by using its form, the input fields for the day and the month are blanked and the input field for the year shows the before prompted year. This is fine, too. But if I blank the day field and fill only the month and the year field, I get the month in full text, followed by the year as value at the Day of birth parameter. So far, no error. But if I edit this article now, using its form, the day is blank, as anticipated, but the month and the year field shows January 1970 at all times and not the month and date value from the template call.

Maybe the localisation is the problem? Since it is a german environement, in case of the month and year only input the month name is saved in german language. This is in accordance with the month dropdown. The month to choose from are also displayed in german language. If I change the parameters value directly without using the form from, for example, the german Februar 1950 to the english February 1950, this "english" value works.

And again many thanks for a note on my struggle with Page Forms in advance! Wgkderdicke (talk) 02:46, 2 June 2018 (UTC)


 * There's no real need to list all the things that do work... I think you could have just described the problem as "Page Forms does not parse dates correctly if they are of the form 'month-name year' when the month name is in a non-English language". Thankfully, I was able to reproduce the problem - I just checked in a fix. Sorry about that. Yaron Koren (talk) 18:50, 4 June 2018 (UTC)


 * Well, that's me. On the one hand, I've always got a knack for making it more complicated than necessary. On the other hand I try to improve my English a little bit on such occasions. So one thing gets to the other and zack, there is the litany... ;-) Thanks for the fix. Wgkderdicke (talk) 21:04, 4 June 2018 (UTC)

monolingual text and input type textarea with autocomplete
I use PF 4.3.1 and have set the form field “keywords” to autocomplete by a monolingual text property “Has keyword”: … but in the form I only get the page to be selectable. If I use a property with normal data type text, then it works as expected. See also https://phabricator.wikimedia.org/T196447. Thank you for resolving this. --Andreas P. 11:15, 5 June 2018 (UTC)

formredlink "create page" bug
Hi, I'm trying to use formredlink in a template with the "create page" option (PF 4.3.1 MW 1.29) with the code:

The template will only display properly after the page is created by the job, but since it is not created, the output is the following: MWException from line 264 of /var/www/html/lab/includes/parser/ParserOutput.php: Bad parser output text.

Backtrace:

Any clue??? Steph.
 * 1) 0 [internal function]: ParserOutput->{closure}(array)
 * 2) 1 /var/www/html/lab/includes/parser/ParserOutput.php(274): preg_replace_callback(string, Closure, string)
 * 3) 2 /var/www/html/lab/includes/OutputPage.php(1879): ParserOutput->getText
 * 4) 3 /var/www/html/lab/includes/OutputPage.php(1900): OutputPage->addParserOutputText(ParserOutput)
 * 5) 4 /var/www/html/lab/includes/page/Article.php(601): OutputPage->addParserOutput(ParserOutput)
 * 6) 5 /var/www/html/lab/includes/actions/ViewAction.php(68): Article->view
 * 7) 6 /var/www/html/lab/includes/MediaWiki.php(499): ViewAction->show
 * 8) 7 /var/www/html/lab/includes/MediaWiki.php(293): MediaWiki->performAction(Article, Title)
 * 9) 8 /var/www/html/lab/includes/MediaWiki.php(862): MediaWiki->performRequest
 * 10) 9 /var/www/html/lab/includes/MediaWiki.php(523): MediaWiki->main
 * 11) 10 /var/www/html/lab/index.php(43): MediaWiki->run
 * 12) 11 {main}


 * Sorry, I don't understand - where are you seeing that output? And does it show up every time you view that page(s)? Yaron Koren (talk) 01:20, 7 June 2018 (UTC)
 * Hi, the error message is the page output, it appears until the redlinked page is created by the job queue. After the redlink page is created, the page output is normal. Steph.
 * Hi Yaron, After extensive tests, I finally found what's triggers the error. And it is weird! It appears that when you have a formredlink with create page option inside a template and that the rendered page has a H1 title (I mean =Title X= ), you end up with an MWException!
 * Let   be a template that contains:

''' =FOO= foo bar, '''
 * Any call to this template in a page crashes MW parser until the target is created.
 * Remove  =FOO=, it works!!! Steph.


 * Wow! I'm glad you discovered that, because I had no idea what could be causing the error. Are you using Header Tabs or some other extension that does some processing to H1-style headers? Yaron Koren (talk) 18:24, 8 June 2018 (UTC)
 * Indeed, Headertabs is installed on this wiki, but the crash appends even without a tag in the page. I'm not aware if the extension triggers some script even when not invoked... Steph.
 * I disabled headtabs and tried again: exception is still fired. I also noted that if the title is set after the formredlink, everything works fine! Steph.
 * It was actually already known : Extension_talk:Page_Forms/Archive_September_2015... Steph.

Dynamic Section Name?
i need:
 * A form to add new sections to an existing page.
 * New section name is passed into form as a parameter (like a template parameter, with 3 curly braces)
 * New section content is entered into form by user.


 * Are you asking about having functionality like the "Add topic" tab in talk pages? If so, Page Forms unfortunately can't provide that. Yaron Koren (talk) 01:21, 7 June 2018 (UTC)

Hi, thx for reply.

Doc says: "A form allows a user to populate a pre-defined set of templates, as well as page sections"

That's what I want. Only difference is, I want to pass the section name to the form, instead of hard coding the section name.

Can the form receive parameters?

Like this: 



Or



Perhaps called with something like:


 * No - none of those will work, unfortunately. Yaron Koren (talk) 04:07, 7 June 2018 (UTC)

How to exclude Class?
Your sample form definition contains: {| class="formtable" ! Author....

If I don't want to include Class, how should that code begin? Like this? {|Author.... Johnywhy (talk) 02:54, 7 June 2018 (UTC)


 * I think it needs to be:

{| ! Author.... Yaron Koren (talk) 04:08, 7 June 2018 (UTC)

template-name in info tag vs "for template" tag?
What's difference between in info tag, and  tag?

Johnywhy (talk) 03:25, 7 June 2018 (UTC)


 * I'm not sure I understand the question. The "info" tag and the "for template" tag do different things... Yaron Koren (talk) 04:09, 7 June 2018 (UTC)

template-name is defined here- https://www.mediawiki.org/wiki/Extension:Page_Forms/Linking_to_forms#The_one-step_process

for template tag is defined here- https://www.mediawiki.org/wiki/Extension:Page_Forms/Defining_forms#'for_template'_tag

What's the difference?

Johnywhy (talk) 04:33, 7 June 2018 (UTC)


 * The template name in the "info" tag is only used to set the page name... if that helps. Yaron Koren (talk) 04:50, 7 June 2018 (UTC)

If   , then how is that different than the "page name" parameter?

Johnywhy (talk) 05:08, 7 June 2018 (UTC)


 * The "template-name" you're referring to is part of the "page name" parameter, no? Yaron Koren (talk) 13:55, 7 June 2018 (UTC)

How To Retrieve Query String Parameters?
i see some examples here of how to load query string. eg query string=namespace=User&User[Is_employee]=yes and |namespace=User|User[Is_employee]=yes

But i don't see example of syntax to retrieve the value of Query String parameters inside the form def.

Johnywhy (talk) 04:32, 7 June 2018 (UTC)


 * Query string values like the ones in those examples get automatically retrieved by the software. But in general, you could use #urlget - it won't necessary work within tags, though. Yaron Koren (talk) 13:57, 7 June 2018 (UTC)

FormStart Page Name vs Info Tag Page Name?
Special:FormStart requires user to enter name of page to edit.

How is that "name of page" different from page name in info tag? Johnywhy (talk) 1:28, 7 June 2018 (UTC)


 * It's the difference between the one-step and two-step processes for page creation, which are covered here. Yaron Koren (talk) 13:58, 7 June 2018 (UTC)

Ah, ok, so i would use one or the other, but not both, correct? Johnywhy (talk) 14:28, 7 June 2018 (UTC)


 * Usually - there could potentially be forms that have a page-name formula and usually set the page name themselves, but also sometimes get a page name manually passed in. Yaron Koren (talk) 16:17, 7 June 2018 (UTC)

Can #arraymap or #arraymaptemplate split string on pairs?
Is it possible to make a variable in template with complex value = "Key1: Value1; Key2: Value2; Key3: Value3", then using arraymap split it on pairs and pass to template which will return formatted string?

For example, if one call template like

The one get result like:
 * Key1 = Value1
 * Key2 = Value2
 * Key3 = Value3

May be there is a trick? Or is it possible to use #arraymap and #arraymaptemplate for single values only?


 * Not sure to understand your needs, but I guess a combination of explode function and arraymap should do the trick.


 * Steph.


 * Thank you, Steph! This is just what I need! #explode is the answer, but to make it work we need to set   for ParserFunctions extension.
 * To make the answer complete and for the ones who may search for such an example, there are two additional templates below to make it work:
 * Template:Make list:
 * Template:Make list item:
 * I put this answer with some more examples to my site. Thanks again! Pavel Malakhov (talk) 03:19, 9 June 2018 (UTC)
 * I put this answer with some more examples to my site. Thanks again! Pavel Malakhov (talk) 03:19, 9 June 2018 (UTC)
 * I put this answer with some more examples to my site. Thanks again! Pavel Malakhov (talk) 03:19, 9 June 2018 (UTC)

defining readonly inputs
In html, it is possible to create a form input that the user can not edit. For example:  I'd like to do this in Page Forms however, in PF, this doesn't work: What can/should I do?


 * The closest you can get is putting "restricted" instead of "readonly" - admins will still be allowed to edit the field, but no one else will. Yaron Koren (talk) 21:54, 7 June 2018 (UTC)


 * As an alternative, you can make the field "hidden" and show a in the form outside of a field definition, so that the date will be seen by user but no input field will. Steph.

How to stop existing sections loading into new section input-box?

 * 1) Create a form call Form:AddItem. Paste in the following:
 * 2) Create a page called Launcher. Add the following code:
 * 3) In read-mode, click that link, enter some test text, click Save.
 * 4) Browse to page MyList. See new section created with your test-text.
 * 5) Edit Form:AddItem. Change section|Monkeys to section|Pies and save the form.
 * 6) Browse to Launcher. Click the "Add Item" button.
 * 7) At this point, the input box contains the text of the previously entered section.

How to stop the text of the previously entered section from showing up in the new form? Johnywhy (talk) 03:50, 11 June 2018 (UTC)


 * I don't know - this may possibly be a bug, since text under a different section header should probably be counted as "free text", not as section contents. You could always just delete the text, though... Yaron Koren (talk) 03:59, 11 June 2018 (UTC)

But, i don't want to delete the text, i don't want to touch the text. I want the form to add a new section to the page, without touching the existing sections. Is it possible? Johnywhy (talk) 04:04, 11 June 2018 (UTC)


 * The only way I can think to do that is by adding a new section to the form, instead of changing an existing one. Yaron Koren (talk) 14:40, 11 June 2018 (UTC)

Ok, thx, that makes sense. Johnywhy (talk) 15:20, 11 June 2018 (UTC)

Some very long page name that will etc.
Hi, I experienced the infamous page name. Seems to me to be related to the info tag "page name" with feature. In my case, a page is created by a form with this tag. Then from the page, other pages are created with a semantic property filled with a reference to the initial page &rarr; template parameter are filled with. In the secondary pages, this reference sometimes ended with "Some very long etc...". I switched to Extension:IDProvider to manage automatic page numbering, and things seems to have settled. I'm a bit frightened by this bug anyway. Is there a known root cause to this? Steph.
 * After more careful study, looks like this is another strike of my old formredlink friend, which seems to randomly disrupt the parser. Steph

[Solved] Stop Category-tag Loading Into Form?
The more general question is, how to load something into the page, without it showing up in the edit fields when you click "edit with form"?

I use free-text with a preload page, to load a category-tag into pages created with my form. The preload page contains:

The form contains 3 sectional fields, which user fills in when running the form.

Dog Name
The page gets created fine. The hidden free-text field correctly loads the category tag.

But when i click "Edit with form", the Category tag gets loaded into the last input-box. Then the user could delete or corrupt it.

How can i prevent the Category loading into the last input-box on 'edit with form'?

Is there a better way to set the category of the created page?


 * Unfortunately, if a form has a "section" followed by the free text, there's no way for the code to know which one the text should go into. But if your form has a template, you could just put that category tag in the template. If there's no template, then there might not be a good solution. Yaron Koren (talk) 14:37, 21 June 2018 (UTC)

Making some progress. I moved the freetext above all the section tags, and the hidden tag is no longer loading into the input boxes on edit-with-form!

But new problem: When i click "edit with form", i get "page already exists, but doesn't use this form". Which makes no sense.

'''How can i get rid of that error message, while keeping the free-text above the section tags? '''

Getting the same error with all three codes below:

Dog Tip
I can't put the category-tag in a template, because i include part of the page with DPL on a DPL page:
 * if i put the  tag above the section tags, then the template-tag gets pulled into the DPL page. That causes the same category to be applied to the DPL page, which i don't want.
 * if i put the  tag below the section tags, then the template-tag gets pulled into the input field on "edit with form", which i don't want.
 * wherever i put the  tag, it causes the form itself to be added to the category `Dogs`, and displays the "edit with form" tab on the form itself-- which makes no sense.

I also tried the following, with a template-tag, but the template tag doesn't go into the page source. It gets lost-- doesn't go into the created page.

How to prevent it from getting lost?

Dog Tip
Johnywhy (talk) 17:10, 21 June 2018 (UTC)


 * I don't understand how the form definition page would get added to the category... I was talking about putting the category tag in the template itself, i.e. in "Template:Dogs" within the "includeonly" section. Is that what you tried? Yaron Koren (talk) 17:55, 21 June 2018 (UTC)

'''Solved. '''
 * i must have manually applied Dogs category to the form itself (the form def isn't causing that). I removed the category from the form-page to get rid of "edit with form" tab on the form itself.


 * The Fix: to keep template-tag from getting loaded into input box, put the  tag ABOVE all the section tags. If you put the   tag below the last section tag, then the stuff transcluded from the template will get loaded into the last input field on "edit with form". Nota bene.

Dog Tip
Johnywhy (talk) 18:20, 21 June 2018 (UTC)


 * What do you mean by "input fields", by the way? Yaron Koren (talk) 18:26, 21 June 2018 (UTC)

By "input fields", i meant the "section" tags. Edited above. Johnywhy (talk) 18:31, 21 June 2018 (UTC)

BUGS? How To Put Static WikiText into Created Page?
The following does display the default value when creating a new page, but then the value does NOT get inserted into the created page. Any fix?

Johnywhy (talk) 18:29, 21 June 2018 (UTC)


 * Putting "nowiki" tags around the category tag may help; I'm not sure. Yaron Koren (talk) 18:37, 21 June 2018 (UTC)

'nowiki' didn't work. Any other ideas? i noticed that, without the 'nowiki' tags, my form got added to the Dog category.


 * Not really... although, if that field will always hold a category name, then the template itself can put the category tag around the name entered by the user. Yaron Koren (talk) 19:16, 21 June 2018 (UTC)

But the user won't enter a category. I want to hardcode the category, and hide it like this: Does that give you any ideas?

I'm just experimenting for a way to avoid using a template. Seems to me that hardcoding the category into a page-creation form should be a feature built-into the form, without requiring a template. Too complicated, too many moving parts. Thx Johnywhy (talk) 19:20, 21 June 2018 (UTC)


 * I see. Well, you can't have a "field" tag without a template. Yaron Koren (talk) 19:32, 21 June 2018 (UTC)

Then how about a "standard input" tag? Johnywhy (talk) 19:34, 21 June 2018 (UTC)


 * Within the "free text" field, you can preload a category tag... didn't you already do that before? Yaron Koren (talk) 19:40, 21 June 2018 (UTC)

Yep, that causes problems, described in topic above:
 * Free-text invades section - With `free text` after the last section-tag: when i click "Edit with form" on the new page, the free-text Category tag gets loaded into the last section-box. Then the user could delete or corrupt it. That's a bug, right? Category tag should NOT get loaded into a section-box.
 * Free-text causes error - With `free text` before the first section-tag: when i click "edit with form", i get error message "page already exists, but doesn't use this form". That's a bug, right? Your code mistakenly assume the category tag will be at the bottom.

Johnywhy (talk) 20:17, 21 June 2018 (UTC)


 * I wouldn't call the first one a bug (it's inevitable); the second one does sound like a bug. I haven't done much testing of forms with no template. Yaron Koren (talk) 20:49, 21 June 2018 (UTC)

Ok, since that's "inevitable", I've updated your manual Extension:Page_Forms/Defining_forms -- Johnywhy (talk) 21:03, 21 June 2018 (UTC)

IMO i would call the first one a bug too. Free-text invading the section should reasonably not happen. You offer free-text as a separate entity. Therefor, your extension should mark-off the free-text in some way. Or at least ignore category tags! Your extension should respect MW standards. By MW standards, when a page is normally rendered, category-tags at bottom of source are never included in last section. MW KNOWS they are NOT part of the last section. But your extension doesn't know they are not part of the last section. Your extension breaks MW.

How to match a particular namespace to a particular form?
I would like to match a namespace to a form. This here I have read. Now I'm a little bit puzzled. Usuallay I create new namespaces by adding them to the $wgExtraNamespaces global variable in my LocalSettings.php file. Initially there is no page in that namespace. How can I locate the page defining that namespace? The projects name is WGKCollect. Lets assume, the new namespace is named Person. If I navigate to the WGKCollect:Person page, I find no page. I have to create this page. How does this needed property look like and what have I to type into that WGKCollect:Person page to add this property? And after typing the property of whatsoever kind, I have to add only this here: ?

Please let me know, what I do not understand here. Thanks for that in advance!--Wgkderdicke (talk) 12:22, 23 June 2018 (UTC)