Jump to content

Extension talk:Page Forms

Add topic

MW 1.43 doesnt seem compatible with PageForms 6.0.6

[edit]

I installed Semantic Wikibase (Mediawiki + Wikibase + Semantic Mediawiki6.0) in a mw1.43 version based on the wikibase docker image. PageForms was installed via Composer with version:"*". Installed PageForms version is 6.0.6. When opening Special:SpecialPages i get the following error:

/Special:SpecialPages Error: Failed opening required /var/www/html/extensions/PageForms/includes/../specials/PF_CreateProperty.php

Same error occurs also on pure Wikibase 1.43 installation. It seems, that in version 6.0.6 the filenames changed from PF_CreateCategory.php to PFCreateCategory.php but somewhere theres seems still a reference to the old names. PageForms version 6.0.5 worked without problems. My Solution was to restrict PageForms version on composer.json to version: "<= 6.0.5"

Sorry about that - I just checked in a fix for it. (And I'll probably have to release a new version of Page Forms soon.) By the way, I should note that I think using External Data to query Wikibase is easier than Semantic Wikibase, but that's a whole separate discussion. Yaron Koren (talk) 14:11, 6 May 2026 (UTC)Reply
Thanks for the fast fix! I rely heavily on SemanticResultFormats in my projects but will definitely have a look at ExternalData Extension. Baillyk (talk) 06:18, 7 May 2026 (UTC)Reply

"editor=wikieditor" textarea fields display as only two lines high on page preview

[edit]

I think this started when I upgraded Page Forms to 6.0.5 after upgrading from MW1.39 to 1.43. Jonathan3 (talk) 12:52, 7 April 2026 (UTC)Reply

What version of WikiEditor are you using? Yaron Koren (talk) 21:44, 7 April 2026 (UTC)Reply
1.5.4, the version bundled with MW1.43.
In response to your question, I downloaded it using git, but the most recent branch that works is REL1_43 (as later branches' extension.json require later MW versions). It also shows up as 1.5.4 and has the same problem. Jonathan3 (talk) 13:48, 8 April 2026 (UTC)Reply
Alright, I see. It appears that this was a bug in WikiEditor that was fixed before the REL1_45 version. Though there's probably a way for the Page Forms code to undo the problem. Yaron Koren (talk) 15:48, 8 April 2026 (UTC)Reply
What caused/fixed the bug? I might patch my WikiEditor code for now. Though it'll be affecting everybody using WikiEditor and Page Forms on MW 1.43, so might be worth fixing at the Page Forms end too. Jonathan3 (talk) 00:34, 9 April 2026 (UTC)Reply
I don't know - it looks like the WikiEditor code had quite a few changes related to preview handling around May-June 2025, so I'm guessing one or more of those fixed the problem. It would be nice to fix the problem in Page Forms, yes. Yaron Koren (talk) 15:36, 9 April 2026 (UTC)Reply
$wgWikiEditorRealtimePreview = false; fixed it for now! Jonathan3 (talk) 16:41, 9 April 2026 (UTC)Reply
Oh, great! Yaron Koren (talk) 16:52, 9 April 2026 (UTC)Reply

"combobox" is freezing the form when used on numbers

[edit]

In a form for books, the field publication_date holds a page from Category:Year. A year is a 4 digits number. When using combobox, the form freezes and we get TypeError: str.toLowerCase is not a function. (In 'str.toLowerCase()', 'str.toLowerCase' is undefined) in the console.
We changed the input type to tokens, with max values=1, and it worked fine but it's a bit ugly, we would like to continue using combobox as before. Is it because of a new version of JavaScript? Amahiant (talk) 13:37, 13 April 2026 (UTC)Reply

If it helps narrow down the problem, I've got a combobox for years with max values=1|cargo table=...|cargo field=YEAR(...) and it works fine. Jonathan3 (talk) 13:48, 13 April 2026 (UTC)Reply
Thanks for letting me know about that - I just checked in a fix, here. Yaron Koren (talk) 20:14, 13 April 2026 (UTC)Reply

Is the parameter Unique broken using Cargo?

[edit]

NameName

It ignores the desired uniqueness of the value. ~2026-34421-12 (talk) 13:48, 11 June 2026 (UTC)Reply

<tr><th>Name</th><td>{{{field|Name|input type=text|mandatory|placeholder=Please enter name here|unique}}}</td></tr>
It ignores the desired uniqueness of the value. ~2026-34421-12 (talk) 13:48, 11 June 2026 (UTC)Reply
Done. It needs cargo table and cargo field. ~2026-34421-12 (talk) 13:52, 11 June 2026 (UTC)Reply

Embedding template tags in free text

[edit]

When using {{#formredlink}}, one can fetch the entire raw contents of a page or template using |preload=Page name or |preload=Template:Name in the free-text box. Is there a way to use just {{Name}} as the lone value in said box instead? --Slgrandson (talk) 21:38, 23 June 2026 (UTC)Reply

What's the advantage of that? Yaron Koren (talk) 22:24, 23 June 2026 (UTC)Reply
@Yaron Koren: Similar to Preloader, in that the tag should be loaded into the free-text field. --Slgrandson (talk) 02:31, 24 June 2026 (UTC)Reply
Oh... I get it, you want that template call to go into the page. What about just putting something like {{{for template|Name}}}{{{end template}}} in the form? That should accomplish the same thing. Yaron Koren (talk) 05:01, 24 June 2026 (UTC)Reply

Mapping templates with input type « Tree »

[edit]

Hello, I was never able to get the mapping template working with "Tree" type fields (I had reported this malfunction a few years ago). Since I don't have development skills, I asked an AI to make it work, and it now works for me. I don't know if this could be useful to anyone else, and I'm not sure how to submit a patch, especially since I'm not its author. However, if it can be of use to someone, I'm happy to make the patch available. L. ~2026-38165-07 (talk) 15:07, 3 July 2026 (UTC)Reply

That's great! Please put the patch anywhere online - pastebin.com, here, or anywhere else. Yaron Koren (talk) 15:49, 3 July 2026 (UTC)Reply
Hi Yaron, thanks for your answer. Here is the patch :
diff --git a/includes/forminputs/PFTreeInput.php b/includes/forminputs/PFTreeInput.php index 422214c1..77a82a2b 100644 --- a/includes/forminputs/PFTreeInput.php +++ b/includes/forminputs/PFTreeInput.php @@ -111,6 +111,11 @@ class PFTreeInput extends PFFormInput { } $cur_value = implode( $delimiter, $pftree->current_values ); + + $allValues = self::collectTreeValues( $pftree->tree_array ); + $mappedValues = PFMappingUtils::getMappedValuesForInput( $allValues, $other_args ); + $pftree->tree_array = self::applyTreeMapping( $pftree->tree_array, $mappedValues ); + $params = [ 'multiple' => self::$multipleSelect, 'delimiter' => $delimiter, @@ -122,12 +127,12 @@ class PFTreeInput extends PFFormInput { 'class' => 'pfTreeInput', 'style' => 'height: ' . $height . 'px; width: ' . $width . 'px; overflow: auto; position: relative;', 'data' => json_encode( $pftree->tree_array ), - 'params' => json_encode( $params ) + 'params' => json_encode( $params ), + 'data-version' => 'v3' ]; - $text = Html::element( 'div', $treeInputAttrs, '' ); - $text .= "<input type='hidden' class='PFTree_data' name='" . $input_name . "'>"; - + $text = Html::rawElement( 'div', $treeInputAttrs, '' ); + $text .= Html::hidden( $input_name, $cur_value, [ 'class' => 'PFTree_data' ] ); $wrapperClass = 'pfTreeInputWrapper'; if ( $is_mandatory ) { $wrapperClass .= ' mandatory'; @@ -210,4 +215,33 @@ class PFTreeInput extends PFFormInput { return $t; } + private static function collectTreeValues( array $tree ) { + $values = []; + foreach ( $tree as $node ) { + if ( isset( $node['text'] ) ) { + $values[] = $node['text']; + } + if ( isset( $node['children'] ) ) { + $values = array_merge( $values, self::collectTreeValues( $node['children'] ) ); + } + } + return array_values( array_unique( $values ) ); + } + + private static function applyTreeMapping( array $tree, array $mappedValues ) { + $newTree = []; + foreach ( $tree as $node ) { + $rawValue = $node['text'] ?? ''; + $node['value'] = $rawValue; + if ( array_key_exists( $rawValue, $mappedValues ) ) { + $node['text'] = $mappedValues[$rawValue]; + } + if ( isset( $node['children'] ) ) { + $node['children'] = self::applyTreeMapping( $node['children'], $mappedValues ); + } + $newTree[] = $node; + } + return $newTree; + } + } diff --git a/libs/PF_tree.js b/libs/PF_tree.js index 07a0142b..7823b3a5 100644 --- a/libs/PF_tree.js +++ b/libs/PF_tree.js @@ -91,12 +91,15 @@ $.fn.extend({ $(this).jstree(options); $(this).bind('select_node.jstree', (evt, data) => { - tree.check(data.node.text); + const val = ( data.node.original && data.node.original.value !== undefined ) ? data.node.original.value : data.node.text; + tree.check(val); }); $(this).bind('deselect_node.jstree', (evt, data) => { - tree.uncheck(data.node.text); + const val = ( data.node.original && data.node.original.value !== undefined ) ? data.node.original.value : data.node.text; + tree.uncheck(val); }); tree.setCurValue(); + console.log('PF_tree.js version v3 loaded'); } }); ~2026-38165-07 (talk) 19:52, 3 July 2026 (UTC)Reply
Is there any way you can put that on multiple lines instead of just one? Yaron Koren (talk) 17:36, 6 July 2026 (UTC)Reply

I've been seeing what AI can do recently (free Claude this time). I asked it: "Put this on multiple lines please." It came up with this:

diff --git a/includes/forminputs/PFTreeInput.php b/includes/forminputs/PFTreeInput.php
index 422214c1..77a82a2b 100644
--- a/includes/forminputs/PFTreeInput.php
+++ b/includes/forminputs/PFTreeInput.php
@@ -111,6 +111,11 @@ class PFTreeInput extends PFFormInput {
 		}
 
 		$cur_value = implode( $delimiter, $pftree->current_values );
+
+		$allValues = self::collectTreeValues( $pftree->tree_array );
+		$mappedValues = PFMappingUtils::getMappedValuesForInput( $allValues, $other_args );
+		$pftree->tree_array = self::applyTreeMapping( $pftree->tree_array, $mappedValues );
+
 		$params = [
 			'multiple' => self::$multipleSelect,
 			'delimiter' => $delimiter,
@@ -122,12 +127,12 @@ class PFTreeInput extends PFFormInput {
 			'class' => 'pfTreeInput',
 			'style' => 'height: ' . $height . 'px; width: ' . $width . 'px; overflow: auto; position: relative;',
 			'data' => json_encode( $pftree->tree_array ),
-			'params' => json_encode( $params )
+			'params' => json_encode( $params ),
+			'data-version' => 'v3'
 		];
 
-		$text = Html::element( 'div', $treeInputAttrs, '' );
-		$text .= "<input type='hidden' class='PFTree_data' name='" . $input_name . "'>";
-
+		$text = Html::rawElement( 'div', $treeInputAttrs, '' );
+		$text .= Html::hidden( $input_name, $cur_value, [ 'class' => 'PFTree_data' ] );
 		$wrapperClass = 'pfTreeInputWrapper';
 		if ( $is_mandatory ) {
 			$wrapperClass .= ' mandatory';
@@ -210,4 +215,33 @@ class PFTreeInput extends PFFormInput {
 		return $t;
 	}
 
+	private static function collectTreeValues( array $tree ) {
+		$values = [];
+		foreach ( $tree as $node ) {
+			if ( isset( $node['text'] ) ) {
+				$values[] = $node['text'];
+			}
+			if ( isset( $node['children'] ) ) {
+				$values = array_merge( $values, self::collectTreeValues( $node['children'] ) );
+			}
+		}
+		return array_values( array_unique( $values ) );
+	}
+
+	private static function applyTreeMapping( array $tree, array $mappedValues ) {
+		$newTree = [];
+		foreach ( $tree as $node ) {
+			$rawValue = $node['text'] ?? '';
+			$node['value'] = $rawValue;
+			if ( array_key_exists( $rawValue, $mappedValues ) ) {
+				$node['text'] = $mappedValues[$rawValue];
+			}
+			if ( isset( $node['children'] ) ) {
+				$node['children'] = self::applyTreeMapping( $node['children'], $mappedValues );
+			}
+			$newTree[] = $node;
+		}
+		return $newTree;
+	}
+
 }
diff --git a/libs/PF_tree.js b/libs/PF_tree.js
index 07a0142b..7823b3a5 100644
--- a/libs/PF_tree.js
+++ b/libs/PF_tree.js
@@ -91,12 +91,15 @@
 		$(this).jstree(options);
 
 		$(this).bind('select_node.jstree', (evt, data) => {
-			tree.check(data.node.text);
+			const val = ( data.node.original && data.node.original.value !== undefined ) ? data.node.original.value : data.node.text;
+			tree.check(val);
 		});
 
 		$(this).bind('deselect_node.jstree', (evt, data) => {
-			tree.uncheck(data.node.text);
+			const val = ( data.node.original && data.node.original.value !== undefined ) ? data.node.original.value : data.node.text;
+			tree.uncheck(val);
 		});
 
 		tree.setCurValue();
+		console.log('PF_tree.js version v3 loaded');
 	}
 });

Jonathan3 (talk) 13:12, 11 September 2026 (UTC)Reply

Looks much better, thanks! I hope this is fully accurate. Yaron Koren (talk) 19:39, 11 September 2026 (UTC)Reply
I am almost 100% sure that it will not be fully accurate, but it'll be easier for you to skim through than the first version. Jonathan3 (talk) 21:14, 11 September 2026 (UTC)Reply
I put it through https://www.diffchecker.com/ and there are some differences, including $.fn.extend({ missing from the prettified one. I asked Claude in a new chat to compare them and it claimed they were exactly the same. But when I pointed out that omission it gave me the inevitable: "You're right, good catch — I missed that." It's pretty good but we are not there yet :-) Jonathan3 (talk) 21:22, 11 September 2026 (UTC)Reply
[edit]

As stated in the docs:

If any part of your query string — such as a page name or anything else — contains characters such as apostrophes ('), ampersands (&), or plus signs (+), you will need to URL-encode that value. For that, you can use the urlencode function from the ParserFunctions extension. The example above, for instance, would need to change to: Quote[Author]={{urlencode:{{PAGENAME}}}}.

However, when we used the {{urlencode:}} to pass the {{PAGENAME}} to the form, it cannot return to the original wording of PAGENAME in the form, but space becomes +; & becomes %38 and so on.

I tried {{PAGENAMEE}} instead of {{PAGENAME}}, but it also is not good.

Could you help any ways to workaround? Duyhungwiki (talk) 12:29, 6 July 2026 (UTC)Reply

Adding template to multi-instance field deletes content in other templates in the same field

[edit]

Hello, I'm using Page Forms 6.0.9 on MediaWiki 1.43.1. I have a template with one field holding multiple templates. The template and corresponding form have been in use for more than a year and worked fine. A few weeks ago (maybe after upgrading to 6.0.8, but I'm not sure) this problem started presenting itself: using the form for adding one new template to the field which holds multiple templates deletes the content of some fields in other templates in the same multi-instance field.

To clarify: the result I expect when I edit the page with Page Forms:

{{Scheda formazione addetto
|Sessioni di formazione seguite=
 {{Sessione di formazione seguita
 |Titolo=Altro
 |Titolo libero=Formazione ISO 9001:2015
 |Categoria corso=Formazione sistemi di gestione
 |Data=2021-01-13
 |Ore corso=2
 }}
 {{Sessione di formazione seguita
 |Titolo=Altro
 |Titolo libero=Formazione Parità di genere
 |Categoria corso=Formazione sistemi di gestione
 |Data=2024-04-19
 |Ore corso=1
 |Note=Online
 }}
 {{Sessione di formazione seguita
 |Titolo=Altro
 |Titolo libero=I sistemi di gestione integrati - Qualità e parità di genere
 |Categoria corso=Formazione organizzata da W.Training
 |Data=2026-05-28
 |Ore corso=1
 }}
}}

The result I get:

{{Scheda formazione addetto
|Sessioni di formazione seguite=
 {{Sessione di formazione seguita
 |Titolo=Altro
 |Data=2021-01-13
 |Ore corso=2
 }}
 {{Sessione di formazione seguita
 |Titolo=Altro
 |Data=2024-04-19
 |Ore corso=1
 |Note=Online
 }}
 {{Sessione di formazione seguita
 |Titolo=Altro
 |Titolo libero=I sistemi di gestione integrati - Qualità e parità di genere
 |Categoria corso=Formazione organizzata da W.Training
 |Data=2026-05-28
 |Ore corso=1
 }}
}}

Important note: the fields that get emptied (Titolo libero and Categoria corso) are displayed conditionally by the form using Show on select, based on the value of the dropdown-field Titolo.

Upgrading from 6.0.8 to 6.0.9 did not solve the problem. Editing via source editor works fine. Thanks for any help! MLWatts (talk) 08:48, 20 July 2026 (UTC)Reply

What version of Page Forms were you using before? It would be helpful to know when the problem started, to whatever degree is possible. Yaron Koren (talk) 12:03, 20 July 2026 (UTC)Reply
When I noticed the problem I was using Page Forms 6.0.8. Before upgrading to 6.0.8 I was using 6.0.1 and everything was working well. MLWatts (talk) 09:55, 21 July 2026 (UTC)Reply
Hey! Just to provide some additional information: I tried upgrading from Page Forms 6.0.8 to 6.0.10 and this did not solve the problem. Then I downgraded from 6.0.8 to 6.0.5 and the problem is not there: 6.0.5 works well. Cheers, MLWatts (talk) 10:36, 3 August 2026 (UTC)Reply

There should be a warning when pre-existing value will be deleted on page save

[edit]

For example:

  1. A form field is defined like {{{field|Subject|input type=tree|list|top category=Things}}}.
  2. The page is saved with the Subject value "Books".
  3. The category "Books" subsequently ceases to exist on the wiki.
  4. The page form is loaded again.
  5. When saving the page, the value "My category" is removed from the template call.

It is at point 4 above where it would be useful if Page Forms could check whether values based on top category are valid, and provide some sort of warning.

I think this might be a problem more widely, but this is where I noticed it today. Thanks for considering this. Jonathan3 (talk) 11:30, 25 September 2026 (UTC)Reply

Using Special:MultiPageEdit to add multiple pages with a random unique number in the page name?

[edit]

I'm using Page Forms (and Cargo) and I want to use the MultiPageEdit to add multiple pages at once, but how does it work when the single form has "page name=Article:<unique number;random;8>" in the info tag to automatically generate the pagename with a random number? I tried to leave the "page" column blank, or just add the "Article:" prefix, but it doesn't work. ~2026-54617-17 (talk) 09:12, 11 October 2026 (UTC)Reply

I think you'll just have to generate the random number, unfortunately. One option is to use Excel, which makes it pretty easy to generate a lot of random integers, with the RANDBETWEEN() function. Yaron Koren (talk) 14:54, 13 October 2026 (UTC)Reply