Extension talk:Page Forms

Show preview button doesn't work
The preview button does work in MW 1.15.3!

After upgrading to MediaWiki 1.16.1 "Show preview" button stopped working in all of the forms, it still works in other pages suck as discussion and other pages that don't have nothing to do with SF.

I am running MW 1.16.1, Semantic Forms (Version 2.0.9) and Semantic MediaWiki (Version 1.5.5)

I don't know if it is relevant but I will mention it anyways, I don't use Properties in my updated MW, just saying maybe somehow Properties are helping to Preview the page.


 * There was a recent change to the script, try replacing extensions/SemanticForms/libs/SF_ajax_form_preview.js by the latest dev version. (Remember to make a backup copy of the original file.) --F.trott 10:04, 3 February 2011 (UTC)


 * Unfortunately it still doesn't work! I do have $wgUseAjax = true; in my LocalSettings and no I don't have my wiki online! I know other people have the same problem, so it is not just me!


 * What exactly happens when you hit the Preview button? Is there any reaction? Javascript errors (Under Firefox see the error console)? Are other people's wikis online, by any chance?


 * Found the problem one of mine extensions were intervening with the SF.

Copying a form result into an another on submission
I saw that there is often some recurring demands for a nested form feature that would allow to edit a template with a form, and populate some of this template fields with "list of templates" that would also have their forms and would be set on a "multiple" setting.

An example of situation where it would be used was posted earlier in the discussions, here

I made a few modifications that allow to use the "multiple" form parameter with a new "replace" parameter. When the form is submitted, the contents of this multiple templates (a series of ... string ) is copied into the template used by the main form instead of having these contents hanging outside of the main template. That way, the user can keep a main template without having to split it into many parts (which would made layout modifications difficult).

Note that the current modification doesn't allow to really have nested forms into the main form. Unfortunately, the other forms will still have to appear outside of the main form, but at least the content will be copied into the corresponding template field, and when this template is edited this field's contents will be taken out of the main form and put as multiple form. Being able to have a real nested form would only require to do a few additional changes in the printing method on top of these modifications.

With all respects to Yaron for this great extension, the code in the formHTML function could benefit from some refactoring, 1000 lines in one single function makes it hard to decipher, even with the comments.

To use, in the form add a hidden field mapped to the template field to populate and declare a replace parameter. After the main form, add a multiple form, having a replace parameter equal to the one declared in the main form.

...

...

The changes are in extensions/SemanticForms/includes/SF_FormPrinter.php, function formHTML. I have put a zip here with the modified SF_FormPrinter.php (version 2.0.9), and a txt file describing a test set(each ****** delimiter indicates a new page to make). The parts modified are marker with //addition and //removal comments (9 areas modified)

--MgLy 08:09, 5 February 2011 (UTC)


 * Hi - this looks very interesting. It's true that the formHTML function is way too large - it's the part of the extension most in need of refactoring, though I'm a little afraid to touch it. :( I'd like to ask you some questions about this code - could you email me so we can start a discussion, or find me on the #semantic-mediawiki IRC channel? Yaron Koren 01:56, 8 February 2011 (UTC)

Making Map Input Required
The code below doesn't seem to force the user to enter in coordinates. Is this a bug? Am I doing wrong? Link to Actual Form Timothy Clemans 22:44, 6 February 2011 (UTC)


 * That sounds like an issue with the Semantic Maps extension - I would ask there. Yaron Koren 15:34, 7 February 2011 (UTC)

Embedded "ask" possible
Hi

I am very happy with SF. I would like to do a little trick, but for now am an not successful. I want do embedd a query but I need to substitute a varaible. What I have tried is this template:

Bearbeite diese Seite, um den Vorlagentext zu sehen.

Is this possible with some little hack? Thanks Chris --178.82.196.210 11:41, 7 February 2011 (UTC)


 * You could just use the variable, instead of hardcoding the name... Yaron Koren 15:36, 7 February 2011 (UTC)


 * Oh, yes this works! Thx! Chris--178.82.196.210 16:51, 7 February 2011 (UTC)

How to deploy SF?
I have 3 media wikis: prod, test and dev. Now I have made a data model in dev and want to deploy the whole thing into test. How do you recommend to do this? Using Special:Export seems not the best way to me because you only can filter the export by category. And using export entry namespace extension seems to have the problem with the "Category" namespace. This is because I want to export semantic categories but not the whole bunch.

Thanks Chris --178.82.196.210 12:53, 7 February 2011 (UTC)


 * This doesn't sound like a Semantic Forms question, but in any case, if you're just talking about the pages for the "data model", it's probably not that many, so you could just manually enter their names into Special:Export. Yaron Koren 15:38, 7 February 2011 (UTC)


 * Hmm ... in fact there are enough pages ... but you are right, I can manually export them. It would be neat if someone could do "export semantic form: xyz" and a "program" is taking care of categories, templates, attributes and forms. Thx, Chris--178.82.196.210 16:55, 7 February 2011 (UTC)
 * When I've had to do this in the past I've tagged each template, form and category (and sometimes main namespace articles that contain queries and business logic) with a category. That then allows me to quickly dump the data model and business logic to an XML file and load it into another wiki. If the category causes problems on some pages, you can tag all the pages with an empty template, and just add the category to that template for the export, and remove it afterwards.  - Borofkin 00:51, 8 February 2011 (UTC)
 * Thats a good idea Borofkin, thanks for the tip! Chris--85.124.73.210 09:41, 8 February 2011 (UTC)

Why do "Text"-Fields get brackets when I use wiki words/tags
I have a simple attribute of type text: But when I enter into the testfiled something like "lala foo ..." the result page is showing Tätigkeiten EN lala foo ..., where foo is a clickable wiki word.

Thanks Chris --85.124.73.210 14:10, 8 February 2011 (UTC)


 * Hi - I bet this is the issue. Yaron Koren 18:16, 8 February 2011 (UTC)


 * Hi, yes sounds in fact like this. "lead to PHP crashes (!) when very long texts are used as values.", would just be cool to know how long "very long" is :-) But I think I can test this out :-) ... tomorrow ...


 * I have setted this to true but its still like before. I cleared browser caches and did a modification on the property .... no luck ...


 * Did you set it to true below the inclusion of SMW? Yaron Koren 19:04, 9 February 2011 (UTC)

populate field from #forminput
Is there a way to populate a field within a form with what is entered in the #forminput text field? --Dgennaro 19:48, 9 February 2011 (UTC)


 * I do not think so. Maybe you could use the one-step process? --F.trott 20:28, 9 February 2011 (UTC)


 * Actually, I think it's possible, if you add stuff like "template-name[field-name]=value" to the "query string=" parameter. Yaron Koren 21:01, 9 February 2011 (UTC)


 * Oh, never mind, I misunderstood the question - you're talking about setting other fields to the page name. You can't do that, but maybe you don't need to, if you tell people something like "leave this field blank to have it be set to the page name", and then use a combination of #if and in the template. Yaron Koren 21:04, 9 February 2011 (UTC)


 * Yeah, I wish I could do that, but they want instant gradification. The best I can do is have two forms. One to add and one to edit (the edit would contain the editable "page name" field). Thanks for getting back to me so quickly. --Dgennaro 22:52, 9 February 2011 (UTC)

Related to this, I would like to set a field's default value to the current page using default= or something similar to what's done with now and current user. I'm using multiple Semantic Internal Objects created by the page's form, and need to set a parent field inside each of these objects to the current page. I figure the best method is to have the page's form pass a hidden field set to the current page name to the internal object template. Is this possible? Maybe there's an easier way to refer back to the parent page for an internal object? Does it make sense as a feature request? --Dmulter 19:46, 23 February 2011 (UTC)


 * It makes sense as a feature request in general, but for your case it seems to make more sense to take the same advice I gave above - use directly in the template. Yaron Koren 21:45, 23 February 2011 (UTC)


 * I can't do it in the SIO object template since the PAGENAME there is the name of the object (PAGENAME#1, etc) instead of the parent page name, and I don't see how the template for the parent can test for field values across multiple SIO objects created using their SIO forms/templates. I understand how I could do a #if for a parent field and then set it to something different. If it helps, the parent is a company page, and the SIO objects are multiple activity entries with fields for date, type, description, plus the parent field. I created a basic example based on my question here, that I'm also using to track down an SIO duplication problem as well. --Dmulter 22:53, 23 February 2011 (UTC)


 * Okay, forget what I said before; the answer's even simpler than that. #set_internal already stores a property pointing to the page it's on - the first one, i.e, "Is activity" in your case. I would rename that property to something more meaningful, like "Is activity for company". Yaron Koren 02:50, 24 February 2011 (UTC)


 * Awesome! I figured it was something simple like that, but never saw it in the docs. I actually use activities for more than just companies, but I fully understand the need for good names. Thanks for the great responsiveness as well. --Dmulter 03:11, 24 February 2011 (UTC)

MW 1.16.2 and FancyBox
I have just upgraded from MW 1.16.0 to 1.16.2 and I have noticed that the FancyBox upload window is now not working correctly. They upload screen now takes up the entire screen and does not navigate back to the form after uploading a file. Please help. Thanks, --Dgennaro 19:50, 10 February 2011 (UTC)


 * Hi - I thought this was fixed in a recent version of SF. If you're not using the latest version (2.0.9), I'd suggest upgrading. Yaron Koren 07:07, 11 February 2011 (UTC)


 * I am running too many wikis. I thought this one had the most up to date version of SF, but I was wrong. Thanks for helping me through this tough time. :) --Dgennaro 15:32, 11 February 2011 (UTC)

Multiple forms → accidental remove?
Hi,

when I use the “multiple” form variant and click remove, there is no warning. I already removed accidentally a form. What about to introduce a JavaScript confirm or step back? I know remove means remove, but just in case … --Andreas Plank 14:43, 11 February 2011 (UTC)


 * Hi - I assume you mean multiple *templates* (actually, the usual term is "multiple-instance templates"). You can, of course, use the history page to restore whatever was deleted accidentally, thought that's sometimes a pain. It would be nice to have an "undo" feature, though I don't think that's possible. And having a "confirm" popup on every removal seems like overkill. Yaron Koren 17:54, 11 February 2011 (UTC)

Do I have to have class="wikitable" in my template?
When I create template using SF i get this line of code added to the template {| class="wikitable" I was wondering do I really need to have that line of code or I can remove it? The reason i am asking is that the line of the code adds some kind of spacing/break on the top of the output page.


 * You can definitely remove it - you can basically structure the template however you want. Yaron Koren 04:51, 14 February 2011 (UTC)

Size of Templates
Out of curiosity, when you use SF with templates, is it easier on the system to have multiple smaller templates, fewer larger templates,fewer partial forms, etc.. or does it matter and why?--76.233.8.127 23:45, 13 February 2011 (UTC)


 * I've never done any real performance testing, but I don't think it matters. Yaron Koren 04:53, 14 February 2011 (UTC)

How tight is the dependency to SMW ?
Hi, It seems (from looking at the documentation) that SF forms can be used to populates templates with no semantic markup at all. I don't want to use SMW on my wiki, but wish to use SF, so I was wondering which parts of SMW are required for SF to work (database tables ? PHP code ? both ? something else ?). --Kevin


 * All of SMW is required - the code and the tables. SF uses SMW for its operation in a number of ways, like the "Has default form" property. Yaron Koren 18:06, 16 February 2011 (UTC)

Edit a existing form
If I would like to create a new form, I can easily create it using a select box to add templates. Is this also possible if I want to edit a existing form? -- Pieter


 * Unfortunately no - all subsequent editing of a form has to be done by hand. Yaron Koren 15:00, 17 February 2011 (UTC)

How to use numbers in scientific number notation in Semantic Forms?
It seems that you can not use numbers in scientific notation ( -1.2e-3 ) in forms - you get "must be a valid number" error. Is there a workaround? SMW accepts scientific notation of numbers so I would expect that Semantic Forms would accept them too...

Possible workaround:

in file SF_FormUtils.php you need to change (works with MediaWiki 1.16.0 and Semantic MediaWiki Version 1.5.1_1 and Semantic Forms Version 2.0.0_1 [B216]):

} else if (type == 'number') { if (field.value.match(/^\s*\-?[\d\.,]+\s*$/)) { return true; } else {

to:

} else if (type == 'number') { if (field.value.match(/^\s*[\-+]?((\d+[\.,]?\d*)|(\d*[\.,]?\d+))([eE]?[\-\+]?\d+)?\s*$/)) { //Allows scientific number notation return true; } else {

Could someone comment on this change to code (for example if it breaks something)?


 * Thanks for this patch! I tested it, and it works great. I just added it to the code in SVN. Yaron Koren 19:03, 20 February 2011 (UTC)

Allowing users to input URL's in form
Hello, I'm trying to set up a form where the user can input an URL. Problem is that URL's that contain an ”=” seem to break the whole thing.

I my form I have something like this:

calling a template that says something like:

Is it possible to have the form urlencode the input of a field? Or are there any other solution to the problem?


 * I think the only solution is to use named template parameters, instead of unnamed (numbered) ones. Yaron Koren 18:46, 20 February 2011 (UTC)
 * thank you you a lot, that solved it! 213.89.102.42 21:22, 21 February 2011 (UTC)

Passing templates and the Use of Partial Forms
My form is getting too large and I would like to utilize partial forms. I'm trying to figure out how to include/pass-along a template from the main form without actually including the fields in the form. Is there a page I can reference? I have been looking for quite some time. Thanks --208.127.139.166 22:07, 19 February 2011 (UTC)


 * You can just have and  without any fields between them, or have fields between them but make them all "hidden". Yaron Koren 18:48, 20 February 2011 (UTC)

standard input|free text
for some reason does not work in my form. The input box appears in the form, I can enter text in the box and save this text in the document created with this form, but the default string XXX does not appear in the input box. Is there anything wrong with my syntax? Kappa 17:24, 2 March 2011 (UTC)


 * No, that should work... what version of MW and SF are you using? Yaron Koren 17:54, 2 March 2011 (UTC)


 * Thank you very much for your quick answer - it already partially solved my problem: I changed SF from version 1.9.1 to 2.0.9, and now the example specified earlier works. The string, however, I really would like to enter is . Unfortunately this strings gets parsed before its insertion and accordingly nothing is included. Is there a possibility to prevent SF from parsing this string?


 * (The application I have in mind is the following: I would like to create a page containing HeaderTabs, which is meant to be common basic information for all users in different namespaces. This basic information then shall be transcluded in pages of the individual namespaces and enriched with further information in these namespaces. Therefore    shall end the page with the basic information but not the transcluding page. Kappa 21:25, 2 March 2011 (UTC)


 * Interesting. Using "preload" instead of "default" might work, although an even better solution might be to include "headertabs" within a new template, and then put that below the free text field - you can do that; the free text input doesn't have to be the last thing in the page. Yaron Koren 22:11, 2 March 2011 (UTC)

REL1_17
While the main trunk has SF2.0.9 at r83144, the REL1_17 branch is still at 2.0.6 , so has not been updated for a while. Are you able to update please? Or am I using the wrong branch to prepare for the imminent release? It seems to be the most up-to-date. $ svn info extensions/SemanticForms Path: extensions/SemanticForms URL: http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_17/extensions/SemanticForms Repository Root: http://svn.wikimedia.org/svnroot/mediawiki Repository UUID: dd0e9695-b195-4be7-bd10-2dea1a65a6b6 Revision: 83018 Node Kind: directory Schedule: normal Last Changed Author: yaron Last Changed Rev: 77626 Last Changed Date: 2010-12-03 00:25:35 +0000 (Fri, 03 Dec 2010) Pete C 13:18, 3 March 2011 (UTC)


 * Hi - I really should put something in the documentation about this, because it's caused problems for a lot of people: those branched versions are useless for most extensions, including SF, and shouldn't be used for SF. You should instead use either the latest code, or the latest tagged version from here. Yaron Koren 15:09, 3 March 2011 (UTC)