Extension talk:Page Forms

Embedding and preloading a query form at the same time?

edit

Hi Yaron, first of all, thank you very much that you still maintain your powerful extensions!

I would like to embed a query form on my page that displays results automatically from the very beginning.

I can embed my form with {{Special:RunQuery/query form name}}, but for some reason it doesn't work if I use {{Special:RunQuery/query form name?template-name[item-name]=value}} or {{Special:RunQuery/query form name?template-name[item-name]=value?_run}}.

Is this supposed to work? Stefahn (talk) 15:37, 15 January 2025 (UTC)Reply

That's a limitation of MediaWiki; I don't know if you can get around it. One option is to add those values as "default" values in the form itself, though that won't pre-run the query. You could potentially do both by adding all those values in to the query string of the page itself, maybe in links to that page. Yaron Koren (talk) 18:33, 15 January 2025 (UTC)Reply
Thanks for your quick reply. I found a way to work around this. If anybody is interested: I installed the extension UrlGetParameter and implemented this wikitext: {{#ifeq:{{#urlget:pfRunQueryFormName}}||{{#ask:MyQuery}}}}
This way my initial query is only shown if the URL parameter pfRunQueryFormName does not exist, i.e. the user didn't hit the search button yet. If the user hits the search button, the dynamic search is shown, but the initial query is no longer shown :)
Still need to find a way to add #My-Search-Section to the URL if the user hits the search button, in order to prevent that the user is taken to the very top after he hit the search button... Stefahn (talk) 18:51, 17 January 2025 (UTC)Reply

How to I Edit a Form

edit

I want to change the order of a couple templates I used in a form. I haven't been able to find a way to edit an already created form. I can edit pages using a form, but that's not what I'm looking for. How do I edit the form itself? Irish brigid (talk) 17:14, 22 January 2025 (UTC)Reply

Just go to the page for that form, at Form:form-name. The form definition is just wikitext, so it can be edited like any other page. Yaron Koren (talk) 23:10, 22 January 2025 (UTC)Reply
Ah. Thanks. Might make more complex edits a little difficult, but at least it can be done. Irish brigid (talk) 03:39, 23 January 2025 (UTC)Reply

"Values dependent on=" does not work

edit

This is described at: https://www.mediawiki.org/wiki/Extension:Page_Forms/Values%2C_mappings_and_autocompletion#Dependent_autocompletion

I've created what I think what should recreate the example given, but it just does not do anything: no matter which value is selected for "Country", all previous values of "City" are suggested for auto-completion.

Template:Restaurant

<noinclude>
{{#template_params:Country|City}}
{{#cargo_declare:_table=Restaurants|Country=String|City=String}}
</noinclude><includeonly>{{#cargo_store:_table=Restaurants}}
{{#template_display:_format=infobox}}</includeonly>

Form:Restaurant

<noinclude>
This is the "Restaurant" form.
To create a page with this form, enter the page name below;
if a page with that name already exists, you will be sent to a form to edit that page.

{{#forminput:form=Restaurant}}

</noinclude><includeonly>
<div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div>
{{{for template|Restaurant}}}
{| class="formtable"
! Country: 
| {{{field|Country|input type=combobox}}}
|-
! City: 
| {{{field|City|input type=combobox|values dependent on=Restaurant[Country]}}}
|}
{{{end template}}}

'''Free text:'''

{{{standard input|free text|rows=10}}}
</includeonly>

Thanks Jonathan3 (talk) 12:47, 3 February 2025 (UTC)Reply

I just tried this, and it works for me. Are there any errors in the JavaScript console? Yaron Koren (talk) 15:15, 3 February 2025 (UTC)Reply
I don't think so. I've tried it on two completely separate wikis and it doesn't work for me. Both are on MW 1.39 and Page Forms master branch. Jonathan3 (talk) 14:59, 7 February 2025 (UTC)Reply

Should "values dependent on=" work with list fields?

edit

Can either of the two fields (e.g. the main "Country" field or the dependent "City" field) be a list field?

Also, what input types are allowed? Thanks. Jonathan3 (talk) 12:48, 3 February 2025 (UTC)Reply

No - only comobobox and (I think) tokens. Yaron Koren (talk) 15:15, 3 February 2025 (UTC)Reply

"displayed fields when minimized=" does not seem to work

edit

When I use this parameter with any field names, it just says "No results". When I don't use the parameter, only the value of the first field is shown.

Previously (based on hazy memory, and the topic at https://www.mediawiki.org/wiki/Extension_talk:Page_Forms/Archive_May_to_December_2024#%22displayed_fields_when_minimized%22_not_working) it (wrongly) used to show every field.

What should I do? Thanks. Jonathan3 (talk) 14:34, 3 February 2025 (UTC)Reply

I just tried this, and it works fine for me, both when the parameter is used and not used. Do you see any errors in the JavaScript console? Yaron Koren (talk) 15:21, 3 February 2025 (UTC)Reply

autoedit removes all subobjects

edit

We just upgraded Page Forms from 5.4 to 5.9.1 and noticed that 'autoedit' functionality which we were using for a very long time to add subobjects to the page is now broken (it was one of the most appreciated and useful feature we used to implement page workflows and used it to record and track workflow transitions: who, when, what).

autoedit link still adds a new subobject (record of workflow transition in our case) to the page (as expected and as defined in the autoedit element) but at the same time removes all 'old' subobjects (records of past transitions).

Any suggestions / recommendations how to make it work again? Were there any changes in the api/functionality we didn't notice/should be aware of?

Page modified via autoedit
{{Specification Requirement
|status=Review
|statement=System shall ....

|transitions={{Workflow Status Change
|workflow=Status
|user=XXX
|endstate=Draft
|timestamp=2024-12-09T16:01:00Z
}}{{Workflow Status Change
|workflow=Status
|user=XXX
|endstate=Review
|timestamp=2024-12-11T13:45:00Z
}}{{Workflow Status Change
|workflow=Status
|user=XXXX
|endstate=Draft
|timestamp=2024-12-13T12:59:00Z
}}

..

}}
autoedit element
  • History is a subobject property holding 'transitions'
  • @WORKFLOWCOUNT properly evaluates to 'number of Workflow subobjects' + 1
{{#vardefine:@WORKFLOWCOUNT|{{#expr:{{#ask:[[History::{{PAGENAME}}]]|format=count}}+1}}}}

{{#autoedit:form=Specification Requirement
|target={{PAGENAME}}
|link text=[[Image:Back arrow.png|link=|20px]] Back to Draft
|query string=Specification Requirement[status]=Draft&Workflow Status Change[{{#var:@WORKFLOWCOUNT}}][uuid]={{UUID}}&Workflow Status Change[{{#var:@WORKFLOWCOUNT}}][workflow]=Status&Workflow Status Change[{{#var:@WORKFLOWCOUNT}}][user]={{CURRENTUSER}}&Workflow Status Change[{{#var:@WORKFLOWCOUNT}}][endstate]=Draft&Workflow Status Change[{{#var:@WORKFLOWCOUNT}}][timestamp]={{CURRENTYEAR}}-{{CURRENTMONTH}}-{{CURRENTDAY2}}T{{CURRENTTIME}}Z
|summary=Changing state to "Draft"
|reload }}
Form_Specification Requirement
{{{for template|Specification Requirement}}}

<div style="display:none">
{{{field|transitions|holds template}}}
</div>

{{{field|status|input type=text|mandatory|size=50|default=Draft|hidden}}}
..display status ..

{{{field|statement|input type=textarea|mandatory|rows=5|autogrow}}}

{{{end template}}}

{{{for template|Workflow Status Change|multiple|embed in field=Specification Requirement[transitions]}}}
{{{field|uuid|default=uuid|hidden}}}
{{{field|workflow|input type=text|size=50|cols=50}}}
{{{field|user|input type=text|size=50|cols=50}}}
{{{field|endstate|input type=text|size=50|cols=50}}}
{{{field|timestamp|input type=datetimepicker}}}
{{{end template}}}

After executing above autoedit all 'old' 'Workflow Status Change' elements which existed on the page are removed and 'transitions' attribute holds only the one 'Workflow Status Change' element for the transition defined in autoedit element.

Previously it was added to the existing list. Mourawi (talk) 23:25, 3 February 2025 (UTC)Reply

What does the #autoedit call look like? Yaron Koren (talk) 06:40, 4 February 2025 (UTC)Reply
I added code snippets above. We use that pattern on many concepts and in many Wiki instances.
It was working with Page Forms 5.4 and MW 1.35, now seems to be broken with Page Forms 5.9.1 and MW 1.39.

Mourawi (talk) 13:44, 4 February 2025 (UTC)Reply

Improvements to "uploadable" inputs - default filename, categorisation

edit

It would be good if the default filename parameter could allow the file extension to be set automatically according to the actual file's extension. This would be useful for images, which could be .jpg, .png etc.

It would also be good if there were a category parameter to categorise the related "File:" page. Jonathan3 (talk) 03:01, 5 February 2025 (UTC)Reply

Special:ask whitelist

edit

Hi,

I'm kind of stuck on how to allow anonymous users to use/access the Special:ask query function, and hope someone here can advice.

I have a Mediawiki 1.39.7 with Semantic Mediawiki extension. The 'special:' pages are locked down so anonymous users can't access them.

The problem is that there is tables that anonymous users should be able download. This is prevented by the fact that the 'special:ask' pages are locked down.

Ex:

https://exwiki.org/wiki/Special:ask/-5B-5BBok::530-5D-5D-20-5B-5BStatus::Gjeldende-5D-5D/-3FBok/-3FKapittel%3DKap./-3FVedlegg%3DVedl./-3FKravtekst/-3FKravtype/-3FKravhensikt/-3FMerknader/mainlabel%3D/limit%3D10000/offset%3D0/format%3Dcsv/sep%3D-3B/filename%3D530.csv


Is there a way to make an exception for the 'special:ask' query so anonymous users can download the complete list?

Toreolav (talk) 14:17, 26 February 2025 (UTC)Reply

This sounds like a Semantic MediaWiki question, no? Yaron Koren (talk) 17:47, 26 February 2025 (UTC)Reply

Access Uploadable Field Filename When Editing

edit

I have a mandatory uploadable field on my page form.

When users edits an existing page that uses that template it shows a 100px width image, an upload option, and a remove option.

I don't want users to be able to replace or remove the image, but I do want them to be able to see a larger thumbnail size of the image.

I can use CSS to hide the uploadable field on the editing page, but is there a way to access the filename for me to populate some [[File:Filename|thumb]] wikitext? 70.160.223.43 00:07, 6 March 2025 (UTC)Reply

Check out the "image preview" parameter here - could this be essentially what you're looking for? Yaron Koren (talk) 04:30, 6 March 2025 (UTC)Reply

form input type tokens and values from concept are not showing all results

edit

Hello,

I have defined the following in a form, for example: forTest

If not many pages are found for the Concept:Test, it works. As soon as the concept has 250 or more pages (approximately, in my current example I have 400 pages), not all pages are found during input. Can I increase a limit here? How do I manage to get all pages offered for selection?

Kind regards 212.77.172.210 16:27, 6 March 2025 (UTC)Reply

Do you mean, even as you keep typing, there are certain pages that never show up? Yaron Koren (talk) 17:51, 6 March 2025 (UTC)Reply
Yes, thats exactly what I mean. Some pages do not show up even if I start typing the name (until the whole pagename has been entered) 212.77.172.210 10:28, 14 March 2025 (UTC)Reply

/index.php?title=Special:FormEdit/Vacation/<pagename> Error: Class "SMWDIProperty" not found

edit

I tried to use a form today and am getting an error. This might be relate to a recent update to SMW 5.0.0-beta. I tried to downgrade back from that SMW version but got an error from update.php, the update might be a one-way street.

ChatGPT tells me "I reviewed the Semantic MediaWiki (SMW) GitHub repository and found that the SMWDIProperty class has undergone changes in recent commits. Notably, the class was renamed to SMW\DIProperty as part of the transition to namespace usage. This change is part of ongoing development efforts to modernize the codebase. For detailed information, you can examine the commit history related to this class in the repository."

/home/<mywiki>/extensions/PageForms/includes/PF_TemplateField.php(164)

#0 /home/<mywiki>/extensions/PageForms/includes/PF_TemplateField.php(196): PFTemplateField->setTypeAndPossibleValues()

#1 /home/<mywiki>/extensions/PageForms/includes/PF_FormField.php(424): PFTemplateField->setSemanticProperty(string)

#2 /home/<mywiki>/extensions/PageForms/includes/PF_FormPrinter.php(1167): PFFormField::newFromFormFieldTag(array, PFTemplate, PFTemplateInForm, bool, MediaWiki\User\User)

#3 [internal function]: PFFormPrinter->formHTML(string, bool, bool, int, string, string, null, int, array, MediaWiki\User\User)

#4 /home/<mywiki>/includes/StubObject/StubObject.php(125): call_user_func_array(array, array)

#5 /home/<mywiki>/includes/StubObject/StubObject.php(155): MediaWiki\StubObject\StubObject->_call(string, array)

#6 /home/<mywiki>/extensions/PageForms/includes/PF_AutoeditAPI.php(953): MediaWiki\StubObject\StubObject->__call(string, array)

#7 /home/<mywiki>/extensions/PageForms/includes/PF_AutoeditAPI.php(130): PFAutoeditAPI->doAction()

#8 /home/<mywiki>/extensions/PageForms/specials/PF_FormEdit.php(113): PFAutoeditAPI->execute()

#9 /home/<mywiki>/extensions/PageForms/specials/PF_FormEdit.php(54): PFFormEdit->printForm(string, string, null)

#10 /home/<mywiki>/includes/specialpage/SpecialPage.php(728): PFFormEdit->execute(string)

#11 /home/<mywiki>/includes/specialpage/SpecialPageFactory.php(1724): MediaWiki\SpecialPage\SpecialPage->run(string)

#12 /home/<mywiki>/includes/actions/ActionEntryPoint.php(504): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)

#13 /home/<mywiki>/includes/actions/ActionEntryPoint.php(146): MediaWiki\Actions\ActionEntryPoint->performRequest()

#14 /home/<mywiki>/includes/MediaWikiEntryPoint.php(200): MediaWiki\Actions\ActionEntryPoint->execute()

#15 /home/<mywiki>/index.php(58): MediaWiki\MediaWikiEntryPoint->run()

#16 {main} Tenbergen (talk) 00:43, 7 March 2025 (UTC)Reply

ChatGPT is right about this one - though this bug was actually fixed (as far as I know) a few weeks ago. That reminds me that I need to release a new version, though. Yaron Koren (talk) 04:01, 7 March 2025 (UTC)Reply
Ah! I was using git branch 1.43; changed it to master and that fixed the problem. Sorry about that. Tenbergen (talk) 04:36, 8 March 2025 (UTC)Reply
Return to "Page Forms" page.