Extension talk:Page Forms/Archive April to July 2023

From mediawiki.org

Auto-fill multi-instance template from previous one

Is this possible? I have in mind a tick box like you often see on a shopping website alongside "Shipping address is same as billing address".

The idea is that the subsequent ones would be mostly the same, so it would be easier to change one or two things than type several. Jonathan3 (talk) 22:30, 13 April 2023 (UTC)Reply

There's no easy way to do that, but what you can do instead is have it say something like "Leave the shipping address blank to use the billing address for shipping" - and then have the template handle it. Yaron Koren (talk) 03:04, 14 April 2023 (UTC)Reply
Thanks. What are the difficult ways? Jonathan3 (talk) 08:55, 14 April 2023 (UTC)Reply
Using a PHP or JavaScript hook to add custom code. Yaron Koren (talk) 16:46, 14 April 2023 (UTC)Reply

Combobox Autocomplete Not Finding Results

Per the documentation, I have a table that contains many items with accents, special characters, etc that also has 800+ items in it (hooray video game inventories). So I'm thus required to use a combobox if I want to enable users to select items from that Cargo table as entries.

This is my code:

{{{field|TXT_VestureName|mandatory|input type=combobox|existing values only|cargo table=ITEMVesture|cargo field=TXT_VestureName}}}

I've also tried adding "with autocomplete" to the combobox but that does not work.

  • I've rebuilt the Cargo table.
  • I've tried pointing it to other Cargo tables on my site that are much smaller by changing cargo table/cargo field--this works fine.
  • I've pasted literal entries that I've copied from the Cargo admin view showing me entries in the table--No matches.
  • All I ever get is "Please enter 1 or more characters." Even if I type something (instead of paste) that I know is in the table, I am told "No matches."

What have I missed? SovereignGFC (talk) 22:43, 17 April 2023 (UTC)Reply

Does this also happen with items with ASCII names, i.e. no accents or other special characters? Yaron Koren (talk) 10:34, 19 April 2023 (UTC)Reply
I have done a test with a small set of special character names:
  • Shakudƍ Chrysanthemum Pendant
  • PartagĂĄs Cigars (Perfectos Finos)
  • MĂ©daille d'honneur (Vermeil)
  • Letter of Regard from Ä°smet Ä°nönĂŒ
This works.
Unfortunately, that means there's something in a table that has over 800 rows that is causing a problem. I will try to narrow it down as I have imported the data in six different sections. SovereignGFC (talk) 00:11, 20 April 2023 (UTC)Reply
Update 4/22/23...
Unfortunately I'm even more confused. I took one of the six chunks, found all entries with non-Latin characters (including ' which apparently counts), and imported that list on its own. Those all worked fine.
I did the reverse, only Latin. This also worked.
But when I import the whole spreadsheet including both the Latin and non-Latin entries, I get "Please enter one or more characters" in the form drop-down.
Something's wrong with the import. When I import JUST the non-Latin from spreadsheet, then JUST the Latin-only (doing it in two parts), it works fine.
SovereignGFC (talk) 19:17, 22 April 2023 (UTC)Reply
This is not necessarily a bug - the "Please enter one or more characters" message shows up when the input uses remote, instead of local autocompletion, which in turn happens when the number of total possible values for that input is above a certain number, by default 200. So that is probably what is happening when you import the entire spreadsheet. The issue is only what happens after you type in one or more characters. Is remote autocompletion not working at all, for any values? Yaron Koren (talk) 22:56, 23 April 2023 (UTC)Reply
OK so I'm on my 101st item. Per the documentation, that causes remote autocompletion.
When I type the name of something I know is in there (or paste it from the table), nothing comes up. It simply says No Matches.
Do I need to check/modify settings on my server/in my installation since that number of items switches to treating my own server as "remote" autocompletion? SovereignGFC (talk) 02:08, 24 April 2023 (UTC)Reply
Oh yeah, 100. Here is one way you can check: open the browser console, and go to the "Network" tab. (Hopefully there's one in whatever browser you are using.) Then type into the autocomplete input. Presumably every character you type will lead to a new API URL showing up under "Network". Go to any of these in a new tab or window - that will show what the API is returning. Yaron Koren (talk) 02:29, 24 April 2023 (UTC)Reply
Got it.
So the final result is this once I've completed typing in the whole value.
Object { code: "internal_api_error_MWException", info: "[ZEaDDQb_wJ5pfNAW-Y93kQAAAow] Caught exception of type MWException", errorclass: "MWException" }
SovereignGFC (talk) 13:28, 24 April 2023 (UTC)Reply
Okay, now we're getting somewhere. Could you please add the line $wgShowExceptionDetails = true; to your LocalSettings.php file? That should make for a more helpful error message. Yaron Koren (talk) 13:51, 24 April 2023 (UTC)Reply
Exception caught: Error: the string "`" cannot be used within #cargo_query.' SovereignGFC (talk) 20:45, 24 April 2023 (UTC)Reply
Okay, that explains it. From March 8 to March 23, there was code in Cargo that disallowed that backtick string in queries. It was removed because it caused some problems, including with Page Forms autocompletion. If you update your Cargo code - or, for that matter, if you keep the existing Cargo code but update your Page Forms code - the problem should go away. Yaron Koren (talk) 14:13, 25 April 2023 (UTC)Reply
Updating to version 5.6.1 resolved the problem. SovereignGFC (talk) 12:38, 26 April 2023 (UTC)Reply
Great! I'm glad to hear that there was no problem with non-ASCII handling. Yaron Koren (talk) 13:46, 26 April 2023 (UTC)Reply

Show on select only working once (first instance of ID)

Is the "Show on select" parameter only supposed to work one time on the page? I'm surprised by this. Unless we did something wrong on our setup. We have recently updated things but I thought it used to work for all instances of the ID specified.

MediaWiki 1.35.6
PHP 7.4.30 (apache2handler)
MariaDB 10.6.5-MariaDB-1:10.6.5+maria~focal
ICU 67.1
Lua 5.1.5
Elasticsearch 6.8.23
Page Forms 5.6.1

Is there any way to make it work for more than one id at a time? For example

{{{for template|Book}}}

{{{field|classification|input type=radiobutton|class=d-block|values=Books, Dissertations, Tibetan Publications, Sanskrit Publications, Other Classical Publications, Periodical Issues|show on select=Books=>books;Dissertations=>dissertations;Tibetan Publications=>tibetan;Sanskrit Publications=>sanskrit;Other Classical Publications=>classical;Periodical Issues=>issues|mandatory}}}

<div id="books" style="color: green;">Section one for books.</div>
<div id="dissertations" style="color: green;">Section one for dissertations.</div>
<div id="tibetan" style="color: green;">Section one for tibetan.</div>
<div id="sanskrit" style="color: green;">Section one for sanskrit.</div>
<div id="classical" style="color: green;">Section one for classical.</div>
<div id="issues" style="color: green;">Section one for issues.</div>

<div id="books" style="color: red;">Section two for books.</div>
<div id="dissertations" style="color: red;">Section two for dissertations.</div>
<div id="tibetan" style="color: red;">Section two for tibetan.</div>
<div id="sanskrit" style="color: red;">Section two for sanskrit.</div>
<div id="classical" style="color: red;">Section two for classical.</div>
<div id="issues" style="color: red;">Section two for issues.</div>

<div id="books" style="color: purple;">Section three for books.</div>
<div id="dissertations" style="color: purple;">Section three for dissertations.</div>
<div id="tibetan" style="color: purple;">Section three for tibetan.</div>
<div id="sanskrit" style="color: purple;">Section three for sanskrit.</div>
<div id="classical" style="color: purple;">Section three for classical.</div>
<div id="issues" style="color: purple;">Section three for issues.</div>

{{{end template}}}

Making it so it'll work on all three sections of elements here, and when Books is selected the three divs with id="books" are shown, all the others are hidden?

Thanks!

Jeremi Plazas (talk) 19:53, 20 April 2023 (UTC)Reply

You can have something like show on select=A=>DivA;A=>DivB, if that's what you're asking. Yaron Koren (talk) 13:45, 21 April 2023 (UTC)Reply
Hi Yaron, no that is not what I meant. But thanks anyways, I found a workaround using a javascript widget. What I was looking for was a show on select that would work for all elements with same attribute (ID [though i know an ID is only supposed to be used once], or a class).
Since this wasn't working and we have too many things to show and hide, I implemented this js code to listen to a radiobutton selection and display all items with a particular classification, and also give a sub-range of values for another "subclass" field:
::	$(function(){
::		$('.help-divs, .sc-values').hide();
::		var checkedValue = $('label.classSelect > input:checked').val();
::		if ( checkedValue == "Books") {
::			$('.help-books, .show-for-books').show();
::			$('.hide-for-books').hide();
::			$('.sc-values').slice(1, 26).show()
::		} else if ( checkedValue == "Dissertations") {
::			$('.help-dissertations, .show-for-dissertations').show();
::			$('.hide-for-dissertations').hide();
::			$('.sc-values').slice(27, 30).show()
::		} else if ( checkedValue == "Tibetan Publications") {
::			$('.help-tibetan, .show-for-tibetan').show();
::			$('.hide-for-tibetan').hide();
::			$('.sc-values').slice(31, 49).show()
::		}
::		etc...
::	});
::
This is working great for us.
Jeremi Plazas (talk) 17:06, 8 June 2023 (UTC)Reply

Editing forms with Minerva Neue mobile version

I try to edit forms with Minerva Neue from a mobile and some troubles happen with JS -- for instance for tokens. An exemple here. I am using the last master branch and Mediawiki 1.39.

Is there a solution to fix it?

Thanks by advance! Manu.wikidebats (talk) 18:42, 28 April 2023 (UTC)Reply

Problems with "Edit with form" tab and preview when using Page Forms

I'm having 2 problems with PageForms in MediaWiki version 1.39.

1. The "Edit with form" button does not appear on pages configured with Page Forms.

- I checked if there was any conflict between the extensions, but there wasn't.

- I cleared the cache.

- The settings are configured correctly.

I would like to know what it could be and how to solve it.

2. When I click to preview a page I'm creating using Page Forms, the preview doesn't work and I get the

following sentence: EditPage does not have a context title set

What could be causing this problem?


Thank you so much in advance! Sakura.tech (talk) 20:26, 28 April 2023 (UTC)Reply

What do you mean by "configured with Page Forms"? And what version of Page Forms are you using? Yaron Koren (talk) 21:14, 28 April 2023 (UTC)Reply
Hello Yaron
I mean by configured with Page Forms, the pages that were created using Page Forms
The version of Page Forms is 5.4 2804:14C:6581:5A74:5889:C932:D29F:4436 03:43, 29 April 2023 (UTC)Reply
See here for how to get the "edit with form" tab to display. Yaron Koren (talk) 15:08, 1 May 2023 (UTC)Reply
Thanks @Yaron Koren the tab is showing now. Regarding the second error, do you know what it could be? 2804:14C:6581:5A74:615F:5257:4FC7:E1BA 19:00, 5 May 2023 (UTC)Reply
What is the full error message, including file and line number? Yaron Koren (talk) 20:44, 5 May 2023 (UTC)Reply
File: EditPage.php, line number 566.
Full error message: "EditPage does not have a context title set"
I don't think it's an error in the code, maybe it could be a bug. When I click on preview to see the page I'm creating with PageForms it says "EditPage does not have a context title set" and I can't see the preview of the page 2804:14C:6581:5A74:615F:5257:4FC7:E1BA 21:10, 5 May 2023 (UTC)Reply
Doing a web search on that error message, this looks like it could be a conflict with either the CodeEditor or TinyMCE extension. Do you have either of those extensions installed? Yaron Koren (talk) 21:48, 5 May 2023 (UTC)Reply
I had CodeEditor installed, I removed it and PageForms worked. But I need to use CodeEditor too, what do you recommend I do in this situation? 2804:14C:6581:5A74:B1B1:AE12:FBC4:ADD9 13:08, 9 May 2023 (UTC)Reply
I don't know... until this bug is fixed, I don't know if there's a real solution. Yaron Koren (talk) 19:13, 9 May 2023 (UTC)Reply

Remote autocompletion: final part of string replaced with hash

This issue has come up before, e.g. in the archives here and here. The problem can still be reproduced on the website of the user who posted in 2017: https://wiki.fabricioassumpcao.com/w/api.php?action=pfautocomplete&property=Bibliographic_review&substr=campo%20500 .

Does anyone know of a solution, or where we might look for one? Could it be related to the maximum search length of 40/72 characters and if so, would it help to set smwgFieldTypeFeatures to SMW_FIELDT_CHAR_LONG ? At its core, it's probably an SMW issue, but the context is squite pecifically PF. Rand(1,2022) (talk) 17:02, 20 May 2023 (UTC)Reply

Define forms to appear on "form chooser"

Hello,

Am looking for a way to list or not list a specific form when $wgPageFormsLinkAllRedLinksToForms = true; is defined on localsettings.

Alternatively, the way define principal and other form on the listed choice.

Thanks for your help! Willyedoo (talk) 10:13, 24 May 2023 (UTC)Reply

Unfortunately there is no way to customize any of it - whether forms show up at all, or whether they show up in "Main forms" or "Other forms". What kind of customization would you want to have? Yaron Koren (talk) 14:00, 24 May 2023 (UTC)Reply
Customizing what falls to "main forms" and what falls to "Other forms" will be usefull in that case.
In my UX designing, seaching and being able to use the must apporpriate form is a must. Actually I have Two i want for "Main forms" in total of four showing up now.
Thanks for your help! Willyedoo (talk) 15:02, 24 May 2023 (UTC)Reply
Okay, that's interesting. Right now the logic is that forms show up in "Main forms" if the number of pages that are editable with that form are more than 1% of the total number of pages in the wiki that are editable with any form. That 1% number is hardcoded - would it solve your problem if that number were settable in LocalSettings.php? Yaron Koren (talk) 15:20, 24 May 2023 (UTC)Reply
Hi Yaron,
Absolutely, it will solve my problem if i can change it on LocalSettings.php.
Thanks! Willyedoo (talk) 09:16, 25 May 2023 (UTC)Reply
That's good to hear - I was planning to add a setting for that at some point anyway. I just added the global variable - it's called $wgPageFormsMainFormsMinimum, and by default it's 0.01. If you get the latest code, you can use that setting to increase or decrease the number of "Main forms". Yaron Koren (talk) 15:16, 25 May 2023 (UTC)Reply
Many thanks,
I will update and customise accordingly.
Nice day! Willyedoo (talk) 07:44, 26 May 2023 (UTC)Reply
Hello Yaron,
When i updated the code, the issue was fixed for form choosing, but a new issue appear on data loading from categorie. Only light categories load, when the category is important nothing load.
Am using this code to load data:
input type=tokens|values from category=XXXX|list|delimiter=;}}} 163.62.112.85 13:19, 30 May 2023 (UTC)Reply
It's great that the form chooser thing is fixed. For this new problem - please create a separate section for it; otherwise it gets confusing. Yaron Koren (talk) 13:36, 30 May 2023 (UTC)Reply

Autocomplete on multiple Cargo fields

Is it possible for a tokens field to autocomplete on multiple Cargo fields?

Or on the result of a Cargo query (which could have the same effect)?

Thanks. Jonathan3 (talk) 14:22, 25 May 2023 (UTC)Reply

If it's a relatively small number of values (say, 200 or less), you could do it just by hardcoding "values=" to a #cargo_compound_query call (don't forget to add "no html" to the query). For a larger group of values, I don't think there's any way to do it, unfortunately. Yaron Koren (talk) 15:23, 25 May 2023 (UTC)Reply

Edit With Form + Dates

When I load an already-created page that has a parameter (or in this case, four parameters) which are defined as Dates in Cargo, Page Forms blanks the values.

I compared the value saved when I fill in the Page Form and the value in the template page. They are identical. Originally I had the date as 01/15/1999 but realized Page Forms saves as 1999/01/15. Despite matching that up, Page Forms still blanks the date that was already there unless I put it in again when editing.

thumb



SovereignGFC (talk) 21:23, 28 May 2023 (UTC)Reply

That's pretty bad. What version of Page Forms are you using? Yaron Koren (talk) 02:34, 29 May 2023 (UTC)Reply
I diagnosed the problem this morning.
I had two divs with the same template variables. If dropdown select A, hide divs. If B, show div 1. If C, show div 2 (which is the same as div 1 + an extra field).
I solved the problem by removing the duplicate template variable calls and accepting that I'd have the C div show for both B and C cases, meaning for B the extra field simply isn't filled (even though it's shown). SovereignGFC (talk) 18:45, 29 May 2023 (UTC)Reply
Ah, yes - you can't have duplicate field names, unfortunately, even if only one at a time is shown to users. Yaron Koren (talk) 13:41, 30 May 2023 (UTC)Reply

Form loading field data issue

Hello,

I update my page form recently, and it don't load data on field where data seems te be a important. When the field is link to a category with low data, they load fine. When the category have more data, the form keep loading and nothing appear.

Am using this code to load data:
input type=tokens|values from category=XXXX|list|delimiter=;}}}

Thanks for your help! 163.62.112.185 07:34, 31 May 2023 (UTC)Reply

I think you are seeing a bug with autocompletion that was in place for the last two weeks, which I just discovered and fixed yesterday. If you get the latest Page Forms code again, the problem should hopefully go away. Yaron Koren (talk) 13:05, 31 May 2023 (UTC)Reply
Hello Yaron,
I tested the latest code again and found some issue on data loading. Now it shows some data when we start writing on the field but the system isn't acurate and keep showing some text and "rows" of number(0,1,2,3...) as a result.
In total some progress but not yet acurate on indexing the content of a category. Willyedoo (talk) 13:44, 6 June 2023 (UTC)Reply
That's strange - are you saying that 0, 1 etc. are showing up as autocompletion results when you start typing? If so, do the same values show up no matter what you type? And by any chance, do you have the DisplayTitle extension installed? Yaron Koren (talk) 17:02, 6 June 2023 (UTC)Reply
Hello Yaron
Yes the values texte typed and (0,1,2,3...) appear no matter what is typed.
Yes i have the display extension installed.
Thanks! Willyedoo (talk) 08:19, 8 June 2023 (UTC)Reply
That is strange - it sounds like there's something unusual going on with mapping, although I don't know what it is. Could you try briefly disabling the DisplayTitle extension, and see if that autocompletion problem still happens when it is disabled? Also, do those values appear even when there are no autocompletion results for that string? Yaron Koren (talk) 12:47, 8 June 2023 (UTC)Reply
Hi @Willyedoo, work is in progress to revise some of the mapping options. We're tryimg to divide these revisions into a sequence of patches but it is possible that some interdependencies have been overlooked. In this case, I suspect that the change from indexed to associative arrays is only halfway there, but I will need to look into that. It would be helpful for me to know whether local or autocompletion is being used. You can probably tell by opening up the browser console and see if theere are calls to the API when you start typing something in the tokens field. If so, it means that the form field is using remote autocompletion. Could you check ? Rand(1,2022) (talk) 10:32, 9 June 2023 (UTC)Reply
Hi @Rand(1,2022),
Am working with edge and i don't see any API call. Unfotunately, I don't have right to add extesion on my browser and console isn't acessible for other web browsers.
Thanks! Willyedoo (talk) 15:00, 9 June 2023 (UTC)Reply
Okay, I can reproduce the issue and probably identified the flaw in the code (it wasn't me but a new function intended to sort by string length which accidentally messes up the array). I'll submit a fix, probably within a few days. Rand(1,2022) (talk) 17:10, 9 June 2023 (UTC)Reply
Hi Rand,
I just tested and it works fine so far!
Thanks! Willyedoo (talk) 08:53, 10 July 2023 (UTC)Reply

Email notification upon form submission?

Hi all, Any solutions or I'll settle for tips or suggestions for getting alerted of new form submissions? Will watchlisting the category that the pages created land in work? Any way to get email notifications somehow?

Thanks so much!

I have looked at CI Forms extension which does provide that functionality it seems, but it won't let you upload files (using an "uploadable" field), so that's a no go. And anyways PageForms is clearly the superior plugin... ;)

Jeremi Plazas (talk) 17:13, 8 June 2023 (UTC)Reply

That's nice of you! I think the best course of action is to use the EditNotify extension, which I believe supports the kind of the thing you're asking about. Yaron Koren (talk) 19:33, 8 June 2023 (UTC)Reply
Thanks Yaron, that should work great!
Jeremi Plazas (talk) 16:11, 19 June 2023 (UTC)Reply
Hi Yaron, so i have installed the EditNotify extension and have played with it thoroughly. Unfortunately, it seems to be pretty buggy for my installation (MW 1.35.10). The "action=create" option will notify any and all creations and edits to the users specified, regardless of any other parameter. The "action=edit" option also disregards all other parameters, but at least will omit page creations. Anyways, that's less than ideal. I've posted on the Extension's talk page and also on T240656 which you contributed to.
Anyways, we'll see if anything happens. We might also be updating all our sites to 1.39 at some point in the near future. Maybe that will offer some solutions... or new problems.
Thanks anyways for your help, as usual!
Jeremi Plazas (talk) 22:24, 21 June 2023 (UTC)Reply

Several question about using PageForms with existing templates

Hi, I just started to read more deeply about PageForms and it's seems amazing!

  1. I have some templates that their major job is to save data to cargo, I created then long time ago and they don't contain "template_params"&"template_display". I created a Form that use this template and it worked. I'm asking because I want to use it with more complicated templated - should it work as well? (I could not find it in the doc, I just saw why it's important to have these 2 func but not if they are mandatory)
  2. I saw this great trick: "query string=namespace=MyNameSpace&=Page Forms/Archive April to July 2023" (to open a new page with the given name from a form), if I want to open a pagename based on the input fields from the user, that possible somehow?
  3. I'm not sure how it's work in the background, but If I have a template called "template:save_book_data" that save to cargo and does some more stuff, and I have books pages that looks like: 1. call to "save_book_data" template, 2.have inline data outside of the template. 3. call to other template. Can I use PageForm to edit them? does PageForm will know to edit only the relevant template from this page or it will replace it all? Thank you very much!

Koshob (talk) 14:39, 9 June 2023 (UTC)Reply

Hi -
  1. Yes, that should work fine - those two parser functions are optional.
  2. I don't understand this question.
  3. That should work fine - basically, any text in the page that is not related to the template(s) in the form is simply considered "free text", and is left untouched. (Unless the user edits the free text in the form.) As long as the "save_book_data" template call is at the top of the page, there should be no problem.
Yaron Koren (talk) 17:03, 9 June 2023 (UTC)Reply
Thanks!
2. I have a Form named "Add Book", at first phase I'm inserting the page name, and after it I'm adding some details like book name, author and so on. As I understand the page name will be what the user inserted at the first place, but if I want the page name to be "calculated" from the user input, for example like this: "{{{BookName|}}}_By_{{{Author|}}}" and I don't want that the user will insert it (I just gave an easy example), that possible somehow?
3. I just tried it myself and if the template is not the first it's moving it to be first, there is anyway topreserve the template p:lace in the page? even with some magic to be written before and after?
Thanks you :) Koshob (talk) 22:21, 9 June 2023 (UTC)Reply
Hi - for #2, please check out The one-step process - that might be what you are looking for. For #3 - what is the little bit you want to add at the top? Could it be integrated into the "save_book_data" template? Yaron Koren (talk) 19:28, 14 June 2023 (UTC)Reply
  1. 2 - looks great!, regarding #3: If it could I wouldn't ask :), I just have another template I have at the top, if I'll merge them the second template will have tons of parameters which is not ideal. Thank you for the help! Koshob (talk) 09:57, 16 June 2023 (UTC)Reply
    Oh, okay. Well, if that second template is always there, the other option is to simply add it to the form definition, above the other template. That would be the better option, actually. Yaron Koren (talk) 13:17, 16 June 2023 (UTC)Reply

Cargo Where On Dropdown Select

So I have a dropdown field. Let's just say it's colors for the sake of an example. Red, blue, green and form field TXT_Color.

I have a field on the same form using tokens like this: |input type=tokens|cargo table=ColorThings|cargo field=TXT_ThingName|cargo where=TXT_Color=I want this to depend on the dropdown.

If the dropdown select is RED, the items on the token list should be: Apple, Fire Hydrant, Cardinal. If the dropdown select is BLUE, the items on the token list should be: Sky, Blueberry, Fish. If the dropdown select is GREEN, the items on the token list should be: Plant, Broccoli, Lizard.

I don't want the token list having all 9 options from table ColorThings, only 3 depending on what color is selected further up on the form in TXT_Color.

Is that possible? SovereignGFC (talk) 15:17, 25 June 2023 (UTC)Reply

Yes, it's possible, but you wouldn't use "cargo where" for that - you should use "values dependent on". Yaron Koren (talk) 13:23, 26 June 2023 (UTC)Reply
...I think I found a new way to push past capabilities.
So the drop-down is associated with template A.
But the values would be from template B.
It doesn't seem to work that way.
{{{field|TXT_TraitsList|existing values only|input type=tokens|cargo table=ITEMTrait|cargo field=TXT_TraitName|values dependent on=ITEMCrew[TXT_Department]|mapping cargo table=ITEMTrait|mapping cargo field=TXT_TraitName|mapping cargo value field=TXT_TraitID}}}
Traits have a Source in the ITEMTrait table--e.g. Engineer.
The Department is a different template and value, ITEMCrew[TXT_Department] but that also contains things like, Engineer. SovereignGFC (talk) 18:24, 30 June 2023 (UTC)Reply
I'm not sure I understand this. What is the connection between the ITEMCrew template and the ITEMTrait table - does one define the other? Yaron Koren (talk) 17:45, 4 July 2023 (UTC)Reply

One form to query all the Wiki's data

Hello,

I'm trying to create a form that could be used to query everything in my Wiki.
It should be working this way :

-The solution has 2 Templates and one Form.

-I want the form to generate a concept definition that will be used on a concept page to display the list of results from the query. It will also generate a table inside which the properties are displayed.

-Parameters from the template are so : The category, operators for the formula, the property and its value. If the query needs to be more accurate, the template can be called multiple times.

Template for the form : (Let's call it WOW)

{{#concept:
{{{Example|}}}
}}

{{#ask:
{{{Example|}}}
|?Catégorie=Catégorie(s)
|format=table
|order=descending
|mainlabel=RĂ©sultats
|default=Aucune page n'a Ă©tĂ© trouvĂ©e, veuillez prĂ©ciser votre requĂȘte.
}}


{{{Example|}}}

is the embedded template inside my form so i can call it multiple times without declaring multiple #concept and #ask.


The form :

{{{for template|WOW}}}

{{{field|EmbeddedValues|holds template}}} (used here)

{{{for template|Example|multiple|embed in field=WOW[EmbeddedValues]}}} (embedded template)

{| class="formtable"
! Catégorie: 
| {{{field|categorie|input type=tokens|values from namespace=Category}}}
|-
! Logique: 
| {{{field|logique|input type=combobox|values=OR,AND|show on select=...}}}
|-
! Attribut: 
| {{{field|attribut|input type=tokens|values from namespace=Property}}}
|-
! Valeur: 
| {{{field|valeur|input type=text|show on select=...}}}
|-
! Logique: 
| {{{field|logique2|input type=combobox|values=OR,AND}}}
|}

Explanations :
-Field for the Category to search. (Values from namespace category)(Can be blank, generates no code then)
-Field for the logical operator for this part of the query. (OR/AND) (Only shows if there is a selected category)
-Field for the property to search. (Values from namespace property)
-Field for the value of the property above. (Only shows if there is a selected property)
-Field for the logical operator if more queries are needed.(Can be blank)
All this parameters are in the Example template. So we can call it multiple times without calling the #concept and #ask as i said before.

The template:Example  :

[[Catégorie:{{{categorie|}}}]] 
{{{logique|OR}}}
[[{{{attribut|}}}::{{{valeur|}}}]] 
{{{logique2|OR}}}

They are the parameters in the form that will be called multiple times if needed. This is the formula for the concept and the #ask. I won't explain everything to make it shorter, so my problem comes when i create a concept with my form.

The query seems to work since the code generated looks like :

[[CatĂ©gorie:Ville]] AND [[Nombre d'habitants::≄1000000]] OR [[CatĂ©gorie:Pays]] OR [[Continent:Europe]]

Here i used the template Example twice.
As far as i know, this query seems to be working, i even tried to use it in the Special:Ask page, and it worked. But unfortunately, the only thing that work in my concept is the first use of the template. It means that only :

[[CatĂ©gorie:Ville]] AND [[Nombre d'habitants::≄1000000]]

Is interpreted in my query.
Also, some "«" "»" appears in the concept definition resulting from my form. I don't know why they appear since they are nowhere coded, i neither know what they are used for and if they can cause any trouble in the query.

So here are my questions, when i create a new concept through this form, why only the first call of the template Example is working since the formula seems to work fine by itself.

Can the "«" "»" cause any trouble in the formula for the concept, and if yes, how can i fix them ?(I can't copy/paste them, they only appear at random places in the concept definition on the concept page, or i just don't understand how they work.)

When i create the new concept through this form, what is the interpreting order from media wiki ?
Is the template interpreted twice, once during the call from the form, and once in the concept definition ? And is this the reason why it is not working ?
I don't get why the formula works on the Special:Ask page and not in my concept definition...
I think the only reason why it does that is the order of interpretation from media wiki, let me know if you think the same too.
If you notice any code error, don't hesitate to tell me.
And of course, if you know or already have the code to do a unique query form, i'll be glad to see it. Thanks for your reading and for your upcoming answers.
Have a great day ! 193.56.33.6 12:29, 4 July 2023 (UTC)Reply

Is the issue here with the form, or with the templates? In other words, are you able to create a page, by hand, that does what you want it to do? If not, then it's probably a Semantic MediaWiki issue, not a Page Forms issue. Yaron Koren (talk) 17:51, 4 July 2023 (UTC)Reply
I think i found where the issue comes from.<br>
I tried to call the template for the concept definition alone in a new concept, one call worked, two didn't as expected.<br>
I spotted a pattern for the "«" "»", they appear between a whole definition, so this is not normal if they appear more than twice in my concept definition considering i want only one definition.<br>
I also realized that spaces in the definition could potentially create many definitions inside the same #concept so i declared a blank by default value to all my parameters. Unused logical inputs parameters does not add a space anymore.
So now, i only have "«" "»" at the beginning and ending of my concept definition even if i call the template multiple times.<br>
Creating the concept definition through multiple calls of the template works fine so far.<br>
So the issue was not coming from the template or the form, but from the way spaces are interpreted in the concept definition.<br>
I guess i'm lucky this issue is not coming from the Page Forms extension.<br>
But i still have no clue why it does that with spaces while imputing them by hand doesn't cause any trouble.<br>
Thank you for your answer. 193.56.33.6 08:00, 5 July 2023 (UTC)Reply

Upgrading from old MW and SMW install

I have the job of upgrading an old MW install from version 1.22.3. It has installed Semantic MW 1.9.1.1, and Semantic Forms 2.7.

In terms of semantics, I am only using ~12 properties, and I have one page-creation form for end users to add entries to a catalog. There would be around 100 pages now that use the properties. I want to be able to generate lists like search results, like here are all entries with property X = Y, that's still to-do.

I studied the guide at semantic-mediawiki.org/wiki/Help:Upgrade which has numerous pages for different situations; this one semantic-mediawiki.org/wiki/Help:Upgrade/Upgrade_from_SMW_1.9_to_SMW_2.1 should be us. I tried this but update.php and setupStore.php would not run, failing with an "incompatible MW version" error. (So now I don't trust the SMW notes.) I could try older versions I suppose.

But on looking at PageForms now I see that Cargo might be a better choice for us, or even just PF on its own, as it's advertised to work independently. I'm unclear as to where the limits are.

So I'm just looking for advice on the best route to take here, my interim goal being to get to MW 1.35 and then bring all up-to-date.

Will PF on its own handle modest ambitions? Or I will need either SMW or Cargo?

If I were to switch to Cargo, should I try to do the switch at MW 1.22, then upgrade - or after?

Deinstall SWM, upgrade MW, install latest Cargo, then redo the properties / sort out the templates, hope it doesn't make a mess of the DB? MonkeyCraig (talk) 09:29, 12 July 2023 (UTC)Reply

There are various ways to do what you're trying to do. I would definitely uninstall SMW for now, and focus on upgrading MediaWiki (and the other extensions). Once that is done, you can either try to upgrade SMW, or switch to Cargo - either one should work, in theory. (You will definitely need one or the other, if you want to generate those lists.) I would personally recommend Cargo, for various reasons, but really either one should work. Yaron Koren (talk) 12:58, 12 July 2023 (UTC)Reply

User Automatically Taken to Form for New Page When Clicking Red Links Vice Default New Page

I have one form that applies to all the pages in the main namespace, and I have another form that applies to all the pages in another namespace, and a third for all the pages in yet another namespace.

I have Extension:NamespacePreload to load an empty template so if someone clicks on a red link they'd be able to immediately submit the preloaded template to create the page, and then they'd be able to press the edit the form button to fill it out.

However, is there something I could do to take advantage of Special:FormEdit/Form_Name/Red_Link_Title so if someone clicks on a red link they'll automatically get redirected to the FormEdit special page without having to create the page first? 70.160.223.43 19:12, 15 July 2023 (UTC)Reply

I was able to figure it out with .htaccess
RewriteCond %{QUERY_STRING} redlink=1
RewriteCond %{QUERY_STRING} title=(Namespace1|Namespace2):([^&]+)
RewriteRule .* /wiki/Special:FormEdit/%1/%2? [L,R=302]
RewriteCond %{QUERY_STRING} redlink=1
RewriteCond %{QUERY_STRING} title=([^&:]+)(&|$)
RewriteRule .* /wiki/Special:FormEdit/MainNamespaceForm/%1? [L,R=302] 70.160.223.43 11:25, 16 July 2023 (UTC)Reply
Are you applying these forms to the namespaces via the #default_form parser function? If so, then this should be happening automatically - any red link to a page in any of these namespaces should be going to "action=formedit", which in turn should be displaying the correct form. Yaron Koren (talk) 13:23, 17 July 2023 (UTC)Reply
I have that parser function on the category page. Should it be elsewhere? Since they're new pages they're not in that category yet. 70.160.223.43 12:44, 29 July 2023 (UTC)Reply
Sorry for the long delay. Yes, #default_form should not be associated with the categories, it should be associated with the namespaces; see here for how to do that. Yaron Koren (talk) 16:10, 10 August 2023 (UTC)Reply

Input Data Into a Tokens Field

I'd like to have JavaScript be able to add values into a comma separated tokens field. I can see that the html it generates, for my specific instance, is a select with an id of input_5. Can I add fields by having JavaScript interact with this field? 70.160.223.43 19:54, 29 July 2023 (UTC)Reply

Yes, you can do that - there may be easier ways to do it, depending on what exactly you're trying to do, but custom JS is always an option. Yaron Koren (talk) 16:11, 10 August 2023 (UTC)Reply