Extension talk:Page Forms

Latest comment: 2 days ago by Nicholasalanbrown in topic Edit text of "Create or edit" button?

How can I display a list of subcategories of a given category in a dropdown?Edit

I'm building a form where I want to let users select a category in which to place the new page. I've tried getting this list of categories from:

1) Cargo - it appears to only let you query data created to store in Cargo

2) CategoryTree - it seems like you can only render collapsible lists in HTML

3) DynamicPageList3 - this seems to work pretty well, but renders categories as links, not as plain text that can be comma-separated and used with the "values" property.

I could use Cargo to store this list of categories separately but I'd prefer not to create a second source of truth for categories.

Any ideas? Nicholasalanbrown (talk) 04:01, 9 January 2023 (UTC)Reply[reply]

I'm guessing that there are ways to do this with both Cargo and DPL3, but the simplest approach might be to use "input type=tree", with the "top category=" parameter. It's not a dropdown, but hopefully it's close enough - and it will be especially helpful if you ever have more than one level of subcategories. Yaron Koren (talk) 14:04, 9 January 2023 (UTC)Reply[reply]
I use this approach: {{{field|fieldname|input type=tree|list|top category=categoryname|height=500|width=500|depth=1|hideroot}}}.
I've found Cargo's storage of categories in the _pageData table to be completely unreliable (it might just be a problem with my databases) but I think the approach here uses category information straight from MediaWiki. Jonathan3 (talk) 10:37, 24 January 2023 (UTC)Reply[reply]
You must use own template code. Use: Extension:ParserFunctions, Extension:Loops, Extension:Variables and code for DPL which I wrote for you here -- Want (talk) 21:43, 9 January 2023 (UTC)Reply[reply]

Get the value of a field the user has completed/selected?Edit

I have a form that has two dropdowns, one for country, one for state/territory. Is there any way to populate the list of states/territories depending on which country is selected? I have both countries and states/territories stored as categories, the issue is I need one field to react to the value of an earlier selection. How do I get the value the user selects for country? This this would be straightforward with jQuery, wondering if that's the only way or if Page Forms can accomplish this somehow. Nicholasalanbrown (talk) 04:00, 13 January 2023 (UTC)Reply[reply]

Yes, it's doable if you're also using either Cargo or SMW to store the data; see Dependent autocompletion. Yaron Koren (talk) 19:12, 13 January 2023 (UTC)Reply[reply]
After a few days of playing with "values dependent on" I realized this feature does not work as I expected.
For context, I have three Cargo tables/forms/templates: Proposals, Countries, and Regions.
What I want to achieve is the following:
  1. I manage relationships between Regions and Countries by storing a "Country" field in the Regions Cargo table, as well as a field in the template.
  2. In the Proposal form I have two comboboxes, one for Country and one for Region, for the latter I have a "values dependent on=Proposal[Country" property, as I've seen in many examples.
  3. What I was hoping would happen is that after selecting a Country, the Region combobox would only show Regions Cargo table records where the value of "Country" was the same as that I had selected (e.g. if I selected "United States" in the Proposal Form, I'd only see states like "Alabama" appear and not provinces of Canada).
  4. What actually happens is that the "Country" combobox shows only whatever Countries have been included in Proposal data, not all Countries from the Cargo Countries table. Similarly for the "Region" combobox, it shows any Regions stored alongside the selected Country in existing Proposal entries. I am aware that I can fix the "Country" issue by explicitly calling the cargo table and cargo field properties, but I'm not sure how to achieve the desired behavior for "Region."
Is what I am trying to achieve possible with Page Forms? Perhaps it's possible to use the "cargo where" property listed in the docs (I have not been able to find any examples of this). Nicholasalanbrown (talk) 03:25, 18 January 2023 (UTC)Reply[reply]
Right - unfortunately, the way dependent autocompletion is defined, you can only get the dependent values for the region from the "Proposals" table, not the "Regions" table. I'm aware that sometimes that's not the ideal behavior, but that's how it's done right now. One hack you can do to get around this problem is to create a page with a whole bunch of calls to the "Proposal" template, one for each country and region. It's not an ideal solution, because it creates a whole bunch of bad data, but if all the data is confined to one page, then maybe it's not a huge problem. And that way the autocompletion will work. Yaron Koren (talk) 19:10, 18 January 2023 (UTC)Reply[reply]

[solved] How to create page names with underscoresEdit

When creating a new page with PageForms, underscores in page names get converted to spaces by Mediawiki. How can I prevent this? I need a page with the name "test_test" and not "test test". RacingRalf (talk) 09:29, 13 January 2023 (UTC)Reply[reply]

MediaWiki by default doesn't allow underscores in page names; you can get around this problem by calling DISPLAYTITLE - see here for an example. So I suppose you could add a call using a combination of DISPLAYTITLE, #replace (from ParserFunctions) and PAGENAME to the relevant template, assuming you want to have underscores for every such page. Yaron Koren (talk) 19:18, 13 January 2023 (UTC)Reply[reply]
Thanks again Yaron!

[solved] Problem creating page with similar name to old pageEdit

I want to create a new page. The first 91 characters of its title are the same as the first 91 characters of an existing page's title (including 5 for the namespace and 1 for the colon). When I try to create the new page, I am taken to the form for the existing page instead... Jonathan3 (talk) 10:29, 24 January 2023 (UTC)Reply[reply]

Those are some long page titles! Anyway, I assume you're talking about #forminput. Could it be that it's autocompleting on the existing page name? Yaron Koren (talk) 14:45, 24 January 2023 (UTC)Reply[reply]
I concede that the titles are long :-)
The #forminput has an autocomplete on category parameter so I'll see what happens with that removed. Jonathan3 (talk) 15:27, 24 January 2023 (UTC)Reply[reply]
I can't remember which page it was doing this with, and can't get it to happen again today, so it looks like I'll never know. I'll mark it as solved anyway! :-) Jonathan3 (talk) 22:48, 27 January 2023 (UTC)Reply[reply]

Edit text of "Create or edit" button?Edit

Is there any way to edit the text of the "Create or edit" button that appears in step one of the two-step process? Nicholasalanbrown (talk) 02:08, 29 January 2023 (UTC)Reply[reply]

Yes, with the "button text=" parameter of #forminput. Yaron Koren (talk) 20:09, 2 February 2023 (UTC)Reply[reply]
Thanks! I'll try that. Nicholasalanbrown (talk) 02:05, 5 February 2023 (UTC)Reply[reply]

Sort order for inputsEdit

I have a field {{{field|Credential|property=HasCredential|input type=tokens|delimiter=,|size=40}}}. Property HasCredential has a list of allows value entries that is alphabetically sorted. When I start typing in the input field the options come up as driven by the property, but they are not sorted. I had a similar problem with a field {{{field|Section|input type=listbox|size=19|property=HasSection|list|values from property=HasSection|default=N/A}}} which sorted all but one value correctly. I replaced that one with a manual list but that's obviously not desirable. Is there anything I can do to sort the values alphabetically? I searched the discussion pages and similar things have come up occasionally but I didn't find a solution. I asked this question some weeks ago, but that post was archived without any answers, so I am re-posting. Tenbergen (talk) 19:53, 2 February 2023 (UTC)Reply[reply]

That sounds like a bug. Is there any order to the sorting? And do "property" vs. "values from property" result in different sorting? Yaron Koren (talk) 20:11, 2 February 2023 (UTC)Reply[reply]

Nested multiple-fields for planning a rolloutEdit

Hello everyone,

I would like to develope a form to plan a rollout for our IT department. My idea was to have a form with template-fields with the property multiple. So you can add multiple elements via one form.

My approach was to have a page for the main location - building. On this page I add rooms. Inside these rooms I want to add tasks. However, "multiple" seems to not support nesting.

My stripped version of the code looks like this:

<onlyinclude><includeonly>

  {{{for template|Room-Rollout|multiple|add button text=Add room}}}<!--This block should hold multiple tasks-->

    {{{for template|addTask|multiple|add button text=Add task}}}<!--Inside the multiple room element these should be saved-->

    {{{end template}}}

  {{{end template}}}

</includeonly></onlyinclude>

Since this doesn't seem to work, I'm struggeling to find an alternative. I would appreciate if someone could give me a hint for a different approach.

Thank you kindly in advance. Fmilk (talk) 07:16, 3 February 2023 (UTC)Reply[reply]

Yes, unfortunately multiple-template instances can't be nested inside one another - you are restricted to just a two-dimensional table of data within a page, not more dimensions than that. I think the only solution is to have separate pages for rooms and/or tasks. Yaron Koren (talk) 14:03, 3 February 2023 (UTC)Reply[reply]
Return to "Page Forms" page.