Extension talk:Page Forms

Loading Screen
I'm having a bit of trouble adding a loading screen for when you click the submit button on image upload in the Special:UploadWindow. That way the user knows something's happening on long uploads. Any ideas on where in SF_UploadWindow.php I can get that work the best? Thanks

"Edit" tab showing when only "Edit with form" should be
Mediawiki 1.18 - SB 1.8.04 - PHP 5.3.21 - Mysql 5.1.73

The "edit" tab was not available until I made some changes to user rights in order to not require email authentication for regular users to edit pages. (Questy Captcha had eliminated all spam so I thought there was no reason to require email authentication)

But now the "Edit" tab is showing for regular users and I can't seem to figure out the right combination of GroupPermissions to make the "Edit" tab NOT show on pages where a form is used.

LocalSettings:

$wgEnableEmail     = true;

$wgEnableUserEmail = true; # UPO

$wgEmailAuthentication = false; // require email authentication for using any email function (except password reminder which works independently from this setting)

$wgEmailConfirmToEdit = false; // Require a confirmed address to edit pages

$wgGroupPermissions['*']['viewedittab'] = false;

$wgGroupPermissions['user']['viewedittab'] = false;

$wgGroupPermissions['sysop']['viewedittab'] = true;

$wgGroupPermissions['*']['edit'] = false;

ConfirmEdit settings:

$wgGroupPermissions['*'           ]['skipcaptcha'] = false;

$wgGroupPermissions['user'        ]['skipcaptcha'] = false;

$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = false;

$wgGroupPermissions['bot'         ]['skipcaptcha'] = true; // registered bots

$wgGroupPermissions['sysop'       ]['skipcaptcha'] = true;

$wgGroupPermissions['emailconfirmed']['skipcaptcha'] = true;

$ceAllowConfirmedEmail = true;

If anyone can spot where I've gone astray, I would appreciate it.

Thanks in advance!


 * Are the "viewedittab" settings done after the inclusion of Semantic Forms? Yaron Koren (talk) 23:21, 5 September 2014 (UTC)
 * Nope, they we not - but they are now and that did the trick. Thanks Yaron! DaveL (talk) 04:12, 6 September 2014 (UTC)

Problem with language on wiki family
Hi, we love your extension and use it for our software documentation. Thanks for your great work!

Now I ran into a little problem with some language configurations. We run a wiki family (used method is described here, MW 1.21.1, SF 2.6.1) and now for the first time we set up a wiki in English insteat of German. Now SF seems to be confused by that, because some words are in german (like "This is a property of type Zeichenkette".) I already set $wgLanguageCode to 'en' in the shared LocalSettings.php but it doesen`t seem to work. I know there could be a lot of reasons depending on the configuration of our wiki family, but the other extensions work just fine. So I hope someone has an idea or has experienced this problem before.

Thanks! Prev (talk) 08:38, 10 September 2014 (UTC)


 * That really shouldn't happen... could it be that the setting of the language, etc. is being done after the inclusion of Semantic Forms? It should be done beforehand. Yaron Koren (talk) 16:06, 10 September 2014 (UTC)


 * Hi Yaron, thanks for the quick reply. That was my first thought too, so I moved the language setting to the shared LocalSettings.php of the wiki family. So it's definitly beforehand, but the problem remained. Prev (talk) 12:02, 12 September 2014 (UTC)


 * What do you mean by "the problem remained"? The text you referred to earlier has already been set - it's in the page wikitext. Does the same problem keep happening to you now if you create new properties? Yaron Koren (talk) 12:58, 12 September 2014 (UTC)


 * Oh, sorry for being unclear. Yes, the problem remains when I create new properties. Prev (talk) 12:40, 16 September 2014 (UTC)


 * Hi Yaron. We finally found the error - after all it was an error in our wiki family configuration. Thanks again for your help and your great extension! Prev (talk) 08:43, 17 September 2014 (UTC)


 * Oh, that's great to hear. Yaron Koren (talk) 22:40, 17 September 2014 (UTC)

Prepend default filename?
I have a multiple instance template for uploading files, and I'd like to use default filename as the beginning of the users filename. So if the user uploads a file called "logo1.jpg", the destination filename will be "subpagename-logo1.jpg". Is this possible to change?

I thought I could add it to this part of the code in sf_uploadwindow, but everything I do just keeps a destination filename from showing at all. $this->mDesiredDestName  = $request->getText( 'wpDestFile' ); if ( !$this->mDesiredDestName ) $this->mDesiredDestName = $request->getText( 'wpUploadFile' ); Would appreciate any help, since users keep overwriting each others images with dumb names like "1.jpg".

Form/Template Data Has to be on the page?
Excuse this newbie question but what I am trying to do is make a wiki for a game and the loot that is dropped by the different creatures in the game. What I want is to simply be able to run a #Ask on the creature page and a list of what loots the creature has will be listed. Works great! BUT http://wiki.afterworld.ru/index.php?title=DaleTest916 Why do I have to produce also each type of loot listed on the page also. Note the page I linked. The template Creature-Loot looks like this to get the screen I currently have on the page:

=
This is the "Creature-Loot" template. It should be called in the following format: <pre&gt;

</pre&gt; Edit the page to see the template text.

=
======= Now I want to eliminate the individual lines of each loot on the DaleTest16 page. So I remove or remark or get rid of the table in the &lt;includeonly&gt; section of the template. Great the lines are now gone but my #Ask on the page is also empty. The DaleTest16 PAge still lists each of the loots with items like

But since the Template does not have the output table in it, the page itself does not have each individual table visible. Make sense. Now comes why im confused. The data for each loot in listed on my page as {{Creature-Loot just fine. Why do I have to have it be visible for that data to also show up on a #ask statement? Thanks! {{Creature-Loot }}
 * Loot Creature=DaleTest916
 * Loot Item=Dale Blood
 * Loot Maturity=Small
 * Loot Frequency=Often
 * Loot Version=9.1.1.1
 * Loot Still=Yes


 * That's not a Semantic Forms question, but you can accomplish that by replacing the table with something like " {{#set:Loot Creature={{{Loot Creature|}}}|Loot Maturity={{{Loot Maturity|}}}| ... }} ". Yaron Koren (talk) 21:43, 16 September 2014 (UTC)

Mapping template example
Yaron and others, could you please give me a simple example of the new  functionality in a wiki instance? Jaider msg 00:08, 17 September 2014 (UTC)

Multiple template: Edit section SOLVED!
Hello, I have a multiple template that's filled with a form. The template fills sections of a page, running text. I have formatted the first parameter as a section heading. Now, there are the usual "Edit" links on the page next to the section headings. But they are redirecting to the template part (the multipliable part) instead of the form. Is there a way to edit those sections with the form? It would be very nice, if you could only click on the one part and don't have to scroll through 20 parts while editing. This is the template (part):

}}}
Problem: has problem:: Solution: has solution:: ...

And this the form (part):

Title: Problem: Solution: Nothing uncommon. Any ideas if editing multiples with forms in single sections is at all possible? --Zabien (talk) 00:08, 18 September 2014 (UTC)


 * It's not, and you should put in a " " in any one of the templates that appears on that page, so that the "Edit" links don't appear. Yaron Koren (talk) 02:55, 18 September 2014 (UTC)


 * I see, and will do exactly that. Thanks for the quick reply! --Zabien (talk) 12:32, 18 September 2014 (UTC)

Conditional formatting according to properties
Hello, another little question, though I am not sure, if this is the right place to ask it. Is there a simple way of adding conditional formatting to a template that gets filled with a form and annotated properties? Let's say, there is a property:has Priority, and priority A should color the section red, B orange, C yellow… and so on. I've searched and tried a lot, but only found info about conditional formatting for tables.

Goal is to let the user choose an option within a form (+ template) and according to the answer display a certain formatting.

I guess, it's not going to work with the  parser function, instead I've tried to use   like this: 

…

It's not reacting at all, if within  tags, but gives out the value of , when within   tags. (I fear I might have totally misunderstood the concept here?)

MediaWiki uses something like this in the Extension template, but it's hard to make out the relevant parts...

Would very much appreciate any hints. --Zabien (talk) 00:29, 18 September 2014 (UTC)


 * This is indeed not the right place - it's not a Semantic Forms question. Yaron Koren (talk) 02:57, 18 September 2014 (UTC)


 * Okay, thank you, I've tried again there. Should I delete this thread here or just keep it in? --Zabien (talk) 12:47, 18 September 2014 (UTC)


 * It's not really an SMW question either... it seems like a ParserFunctions question. But if you can get an answer, no problem. You can either delete this or not - up to you. Yaron Koren (talk) 13:58, 18 September 2014 (UTC)


 * Oh boy… to me, everything that has properties, is semantic… but, well, I'll see and will have to dive even deeper into parser functions, then. I'll leave this to keep your nice words. Zabien (talk) 14:58, 18 September 2014 (UTC)

Multi-instance template with geographic coordinate with input type=map
I can't seem to get it to work inside a multi-instance template, but it seems to work fine in a "regular" form.

|See screenshot here --Jnatividad (talk) 01:39, 19 September 2014 (UTC)


 * Yes, I believe that's a known problem, unfortunately - part of the larger problem of Javascript (other than SF's built-in Javascript) not working in new instances of multiple-instance templates. Yaron Koren (talk) 14:00, 19 September 2014 (UTC)


 * Thanks Yaron for the quick reply. Can you suggest a workaround? I was wondering if there's a way for me to prompt for number of instances when a form is first created, and then and then dynamically create the instances when the re-edit the form. As you pointed out, the map input type works just fine for existing instances.  --Jnatividad (talk) 21:26, 19 September 2014 (UTC)

Embedding query forms with wpRunQuery=true
I tried to embed a run query form with wpRunQuery=true fails with Error: No form was found on page. Is wpRunQuery=true in combination with embedded run query possible in general?

--Planetenxin (talk) 07:41, 7 October 2014 (UTC)


 * Hi - I think this is a MediaWiki issue; I don't think a query string can be included in the standard page transclusion. I'm not 100% sure about that, though. Yaron Koren (talk) 21:07, 7 October 2014 (UTC)


 * As far as I understood from http://www.mediawiki.org/wiki/Transclusion#Special_pages, this should be possible. --Planetenxin (talk) 12:08, 9 October 2014 (UTC)


 * Oh, I see. Well, perhaps the issue is just that you're using "?" and not "|". Yaron Koren (talk) 13:13, 9 October 2014 (UTC)


 * Yaron, sorry I did not mention:
 * will show the embedded query, but the query is not executed automatically (need to click the button first). --Planetenxin (talk) 07:13, 10 October 2014 (UTC)
 * will show the embedded query, but the query is not executed automatically (need to click the button first). --Planetenxin (talk) 07:13, 10 October 2014 (UTC)


 * Oh. I don't know, then; sorry. Yaron Koren (talk) 13:16, 12 October 2014 (UTC)

Define output values for checkboxes using templates with boolean type
Hi there,

I have a question concerning the output values of checkboxes.

The problem itself

I am creating pages with a form (based on a template) using several checkbox inputs. The parameters in the template have attributes with the datatype boolean.

In the created pages the values of these inputs should not be displayed by "yes"/"no", "1"/"0", ... as these are not quite noticable.

A preferred solution would be a definition of checkmark and cross (with unicode) or something like that, if possible with some increasing style. Nevertheless I have no idea how i can override the standard boolean values, which obviously needs to be the first step.

 My implementation

Template:

... ...
 * attSomeAttribute:: Description of the parameter

Form: ... !style="text-align:left"|Description of the parameter ...

I hope the description of my problem is quite understandable.

Thanks in advance --Marc


 * It is quite understandable! You should have something like this in the template:


 * ...or, instead of "True" there, whatever the checkbox input type sets the value to, if the checkbox is selected. Yaron Koren (talk) 21:17, 7 October 2014 (UTC)

Access Parameter Value from Form Article
Having some fun with dynamic form display based on templates. Wondering if it's possible to pass a parameter to the Form (ie. from #formlink) for use in display of the Form (not as a field value). Basically, to use a  value but outside of the tag, in the Form article. I guess kind of like how a template behaves.

ie. Specify |myparameter=myvalue in the formlink (or with query string=) and then accessing it with in the Form article. I'm trying to pass it the name of a template to use. Would mean I'd only need to maintain one form (instead of 50+) for my application. Thanks! - Lbillett (talk) 01:41, 10 October 2014 (UTC)


 * I don't think you can do that, just because the name of the template (defined in the "for template" tag) isn't parsed. Though it's possible that you could add a tiny bit of code to the SF code to get that working... still, it seems strange that you have more than 50 forms, each with a different template, but with the same set of fields for each (if I understand it correctly). Perhaps there's a way to change the whole thing to just one template? Yaron Koren (talk) 13:19, 12 October 2014 (UTC)


 * Ah, I figured as much. It's a bit of a weird application. My form defines a bunch of generic fields (item1, attr1, item2, attr2, etc) and populates the default= values for each by calling a template. 'telling' the form which template to use via formlink would've been snazzy, but is by no means a deal-breaker. Aim is to generate multiple checklists that display/hide fields based on the date (or other conditions). I think I can define the specific part(s) of each form and pull in the common body via template as per here. Thanks! - Lbillett (talk) 12:07, 14 October 2014 (UTC)

Using Semantic Forms with Semantic Title
I am using Semantic Title to set the Title of a page to the value of a Semantic Property on the page. When I use Semantic Forms to select a value from the category with a dropdown it uses the actual name of the page rather than the Semantic Title in the dropdown box. However when the page is saved it shows the Semantic Title in the field, which is what I want. I'd like to be able to show the Semantic Title in the dropdown rather than the actual title and wondered if anyone has tried this and got it to work. The field definition I am using is:

I've also tried using Semantic Forms Select using a query to work around this problem as follows:

If I enter this query directly on a page it correctly shows the Semantic Title with a link to the correct page, but when I use it in semantic forms the dropdown shows a list of semantic property lookups such as:

Membre550295

and the field after the page is saved shows:

has Owner::Johny

Where Johny is a link to the correct page but I don't want to have the semantic property mark-up showing in the field.

I've also tried using an alternative query with Semantic Form Select as follows:

This correctly shows the Semantic Title in the dropdown. Once the page is saved however, it contains the the value of the Semantic Title but not as a link to the correct page. Instead it is a red link as a page doesn't exist with that title.

Any thoughts would be most welcome.

Duncan


 * Try using the "mapping template" feature, new in SF 2.8. Yaron Koren (talk) 13:20, 12 October 2014 (UTC)

Hi Yaron, thanks for your speedy and helpful response. I tried this suggestion but at the moment it doesn't quite work as expected. I have my field definition as follows:

And the mapping template contains:

|

In this case the dropdown contains a list of entries in the form <-!LINK x:xx->. If I select one of these, the field correctly contains the link to the selected page using the SemanticTitle as I wanted.

I then tried the mapping template containing:

This time the dropdown list correctly showed the semantic names. When I select one, however, the field just contains the text of the semantic name rather than the link.

I wonder if I have misunderstood the function of the mapping template? I expected that the two field statements above would both return a link to the desired page. I expected that the mapping template would just alter the 'alias' of the selected item in the dropdown not the value returned.

I'd be very grateful if you have any further thoughts.

Duncan


 * I don't quite understand - could you clarify what appears in the form vs. what appears in the resulting wikitext? Yaron Koren (talk) 18:51, 19 October 2014 (UTC)

Thanks Yaron for your help and apologies that I wasn't clear before.

I am using Semantic Title on the pages in my wiki. The real title of the page is:

Classero100001

and the Semantic Title of the page, contained in property "Has Name" is:

Uno Metrico

The field definition on the form is defined as follows:

Example 1

In this example the template GetEntityName contains:

|

when selected the field dropdown shows:

and when saved the page shows (as a link to the desired page):

Uno Metrico

and the page source contains:

|Classero=Classero100001

Example 2

In this example the template GetEntityName contains:

The field dropdown contains:

Victoriana Uno Metrico enteprissma

The saved page shows (as a redlink):

Uno Metrico

And the page source contains:

|Classero=Uno Metrico

What I want to achieve is that the dropdown shows the Semantic Titles of the pages (as in example 2) but the field when saved contains a link to the selected pages (as in example 1). I wonder if I have misunderstood the function of the "mapping template" as I expected the returned value to be the same in both cases (eg as in example 1)?


 * Oh, I see. I'm not surprised that either one is failing; though the way in which they're failing is unexpected. But what you need is a #show statement - so if the semantic property that holds the title is called "Title", the template should hold something like " ". Yaron Koren (talk) 01:51, 20 October 2014 (UTC)

Fantastic Yaron, thanks so much - that works perfectly. I hadn't really appreciated the difference between #Ask and #Show in this circumstance, so I must acquaint myself better with these functions. Semantic Forms seems a really powerful Extension so thank you for that too.

Duncan

Support for the pattern attribute
Yaron, it would be cool if Semantic Forms could have support for the html5 pattern attribute, don't you think?

Thus, the  parameter in the   tag would just send the regular expression to the   attribute in html. Without the need for JavaScript, etc. Jaider msg 13:57, 12 October 2014 (UTC)


 * Yes... although the case for that would be stronger if Safari supported it as well. Yaron Koren (talk) 22:10, 12 October 2014 (UTC)


 * Ok, well, at least according to this, Safari "supports the pattern attribute, but do not support form validation, so will not prevent an incorrect value from being submitted, but do support the UI pseudoclasses". So it would not do any harm, I think. And according to this: "Opera 9.5+, Firefox 4+, Safari 5+, Internet Explorer 10 and Chrome 5+ are the only browsers with support for pattern at present [February 26th, 2013]. However, with the browser market moving at a fast pace, the others will soon catch up". Jaider msg 22:40, 12 October 2014 (UTC)


 * Oh, okay. You're right that it wouldn't do any harm; maybe it's a good idea. Yaron Koren (talk) 22:55, 12 October 2014 (UTC)

CSRF
Mediawiki 1.23.5. I get message "This appears to be a cross-site request forgery; canceling save" when hitting save or preview on page Special:CreateProperty. However if I disable Extension:ShortUrl everything works fine. --StasR (talk) 11:16, 17 October 2014 (UTC)


 * Hi - that's unfortunate, although I don't know if there's anything I could do about it. Perhaps the ShortUrl extension's Javascript should be set to not take effect on special pages? Yaron Koren (talk) 16:36, 17 October 2014 (UTC)


 * Hi! As far as I can see ShortUrl extension's Javascript is not inserted into the special pages: sample. --StasR (talk) 21:09, 17 October 2014 (UTC)


 * Oh. I don't know, then. Yaron Koren (talk) 18:45, 19 October 2014 (UTC)

textarea didn't parse the first line of the content
mediawiki 1.24wmf21

when i create a form, having a field, it's input type=textarea

then i edit this form, input something like this: then i got
 * 111
 * 222
 * 333
 * 111
 * 222
 * 333,

i debug these html code, found that the first line"111" is "111 "  222  333  

is there anyone can help? or tell me witch part of the SemanticFoms'code is handling this process. Extirpate (talk) 18:16, 17 October 2014 (UTC)


 * i found that this is not the problem of semanticforms, this is a great extension. My problem is the ul or ol nested in the table cell.

for example:

if i make a normal table, and type in         *1 *1       *1         the first *1 acts innormal, and i don't know how to fix it .Extirpate (talk) 18:17, 17 October 2014 (UTC)


 * You just need to add a newline to the template so that the template parameter that holds that bulleted list is on its own line. Yaron Koren (talk) 18:47, 19 October 2014 (UTC)

Work-around for un-populated red link A very long page name error
When using a semantic form to populate a property of type page which is set to "Create pages with form" I get an error if the page doesn't already exist. The title for the page being edited shows "Some very long page name that will hopefully never get created ABCDEF123" and there is a bunch of garbage in the page. After the page is automatically created by a job the error goes away. I confirmed here that this is a known issue: http://www.referata.com/wiki/User_talk:Yaron_Koren#Unpopulated_red_links_create_Some_very_long_page_name_error.

I'm hoping to figure out a work-around if it is possible in my case. I am able to re-create this with a very basic setup as outlined here:

This is the "Example Form" 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.
 * Form



Ex Field:

Free text:


 * Template

This is the "Example_Template" template. It should be called in the following format: pre

/pre Edit the page to see the template text. Ex Field: Ex Prop::


 * Category (Ex Category)

Has default form::Example Form


 * Property (Ex Prop)

This is a property of type Has type::Page Creates pages with form:: Example Form

I can confirm that replacing this line; Creates pages with form:: Example Form, with something that points to en empty form / template; Creates pages with form:: Auto Create F, which doesn't allow for multiple instances still causes the error.


 * That's pretty bad. I have to confess that I haven't looked into this issue in a while, but my understanding is that, before, it only happened in special cases, and now it seems like it might happen even in basic circumstances. I hope to look at it, but until it's fixed it could be that the best option is just to not use "Creates pages with form", unfortunately. Yaron Koren (talk) 15:31, 27 October 2014 (UTC)


 * Thanks, I hope it is an easy fix. In the meantime I'll try to come up with another way to accomplish what I need.  SubtleAphex (talk) 00:11, 28 October 2014 (UTC)

Default Form displacing position of another Template on same page
I currently have two templates on one page. Both have forms but because you can only have one default form the other one is just there without the form as free text. So the free text is Artist info on top and the second template with form is for albums info below artist info (multiple albums). The problem is every time I edit the albums form which is the current default form when clicking edit-with-form, pushes down the artist info template which is in free text to the bottom of the page. So I have to go back to edit-source and move the artist template back to the top to rearrange it. Is there a method to fix this or a way around to this?


 * You should have both templates in the form - why not have both? Yaron Koren (talk) 19:38, 2 November 2014 (UTC)

noinclude and includeonly
Hi Yaron, a recent post in the SMW mailing list has made me think again about the benefit of transclusion with SMW. The example I gave there was that you have pages that represent news items and a query with the 'Embedded format' would collect, say, the 10 most recent items on one page, much like a blog; but this is only one of many possible use cases.

To control what should get transcluded and what shouldn't, you'd need at least one of the three tags 'noinclude', 'includeonly' and 'onlyinclude'. Unfortunately, though 'onlyinclude free text' provides a limited opportunity, this is not always possible using SF. What do you think about using 'for template' to surround templates with the noinclude or includeonly tags, e.g.

Would this be possible at all? Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 23:47, 3 November 2014 (UTC)


 * It sounds like a massive hack. Why not just query the news data semantically, then display it with a template? Yaron Koren (talk) 00:16, 4 November 2014 (UTC)


 * Storing everything semantically can be quite expensive and SMW is just not terribly good at storing and reproducing larger chunks of text, e.g. SMW has trouble coping with internal links (there's $smwgLinksInValues but it's risky); 'special' syntax (italics and the like) often does not render on Special:Ask, which you'd need to use for 'further results'; etc. In other words, transclusion through the 'Embedded' result format would actually be less of a hack from the user's point of view if only a semantic form offered a little more leverage. Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 08:32, 4 November 2014 (UTC)


 * Well, you can get around the links problem by using #set; but that's clearly only part of the issue. Anyway, I don't know if it would be possible; my guess is no, but I've seen stranger things done with SF. Yaron Koren (talk) 16:58, 4 November 2014 (UTC)


 * Haha, that's true. What would also help is to be able to have multiple instances of non-template 'free text' so that editors can add the necessary tags themselves (that is, before and after the templates in question). In the current situation, there may be one hack which sort of does this even if it's not ideal: use a 'section' at the top, where an editor can add the opening tag, and 'free text' at the bottom, where the closing tag would need to be added. But of course the first option is much to be preferred. Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 23:28, 4 November 2014 (UTC)

Size of the popup window for #formlink
Is there a way to set the size of the pop-up window to such levels that the content is always fully visible and scrollbars do not appear? Where can edit this thing anyway? --Temptuousinsolence (talk) 15:30, 5 November 2014 (UTC)


 * It looks like the size of the window is hardcoded in /includes/forminputs/SF_TextInput.php, at around line 122. It really shouldn't be hardcoded, but that's how it is at the moment. Yaron Koren (talk) 17:29, 5 November 2014 (UTC)

Match Pages of the some namespace to a form
in which page a have to use " Has default form::formname ", i.e, if i want match namespace "X" to a form "formX", where i add the property Has default form::formX ?


 * in MediaWiki:X?, or
 * in Project:X? or where? ("X" is the namespace)...

Crystian