Extension talk:Page Forms

Auto-fill multi-instance template from previous oneEdit

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[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[reply]
Thanks. What are the difficult ways? Jonathan3 (talk) 08:55, 14 April 2023 (UTC)Reply[reply]
Using a PHP or JavaScript hook to add custom code. Yaron Koren (talk) 16:46, 14 April 2023 (UTC)Reply[reply]

Combobox Autocomplete Not Finding ResultsEdit

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[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[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[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[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[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[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[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[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[reply]
Exception caught: Error: the string "`" cannot be used within #cargo_query.' SovereignGFC (talk) 20:45, 24 April 2023 (UTC)Reply[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[reply]
Updating to version 5.6.1 resolved the problem. SovereignGFC (talk) 12:38, 26 April 2023 (UTC)Reply[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[reply]

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

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[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[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[reply]

Editing forms with Minerva Neue mobile versionEdit

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[reply]

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

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[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[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[reply]
See here for how to get the "edit with form" tab to display. Yaron Koren (talk) 15:08, 1 May 2023 (UTC)Reply[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[reply]
What is the full error message, including file and line number? Yaron Koren (talk) 20:44, 5 May 2023 (UTC)Reply[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[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[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[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[reply]

Remote autocompletion: final part of string replaced with hashEdit

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[reply]

Define forms to appear on "form chooser"Edit

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[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[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[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[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[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[reply]
Many thanks,
I will update and customise accordingly.
Nice day! Willyedoo (talk) 07:44, 26 May 2023 (UTC)Reply[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[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[reply]

Autocomplete on multiple Cargo fieldsEdit

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[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[reply]

Edit With Form + DatesEdit

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.

 

 



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

That's pretty bad. What version of Page Forms are you using? Yaron Koren (talk) 02:34, 29 May 2023 (UTC)Reply[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[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[reply]

Form loading field data issueEdit

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[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[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[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[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[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[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[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[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[reply]

Email notification upon form submission?Edit

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[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[reply]

Several question about using PageForms with existing templatesEdit

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" (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[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[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[reply]
Return to "Page Forms" page.