Extension talk:Semantic Forms

From MediaWiki.org
Jump to: navigation, search
An archive box Archives 

Code of "special:CreateCategory[edit | edit source]

Hello there,

at the moment i want something like the "special:createcategory" page, but which creates a category which has to be a subcategory of a category of a certain category tree. Preferably without the option to choose a form for it.

Using a form, it would be something like: {| class="formtable" ! subcategory: |{{{field|subcategory|input type=tree|top category=Knowledge|depth=1 }}} |}

The problem with forms is that it creates pages, and not categories. How could i do to create a "category creator" with my own restrictions?

Thanks.

A "category" is just defined by a page in the "Category:" namespace. Couldn't you just create a regular form like the one you describe, and use it to create "Category:" pages? Yaron Koren (talk) 18:14, 2 June 2015 (UTC)


A form which creates categories? How come? You can create categories with a form, indicating the page created with your form is member of a category, but is there a way to create a form which just creates categories? Maiser(talk)

Modified form and template - duplicated data[edit | edit source]

Hello!

I created a few pages with a form, then I modified the form and the template (I added 5 properties to them in a table). Then on a page when I click on the edit with form button, enter the new inputs and click on save, the data is duplicated on the edited page. The first table doesn't have any values, the second table is filled out with the data I entered, and all other sections are duplicated too. Does anyone know how to solve this problem? 13:53, 5 June 2015 (UTC)

It sounds like you renamed the template at some point? If so, you can use the Replace Text extension to modify all the existing pages to use the new template name - or just edit them manually, if there aren't too many. Yaron Koren (talk) 18:10, 5 June 2015 (UTC)
Thank you for your quick response, but that's not the case, I didn't rename the template, I just added a few new properties to it. What else could be the problem? 13:24, 8 June 2015 (UTC)
It would help to see the form and template. Is this a public wiki? If not, could you pastebin them? Yaron Koren (talk) 14:02, 8 June 2015 (UTC)
Of course, though I've already found out what the problem was. This was the bad one: http://pastebin.com/mNVhqppy and this is the working one: http://pastebin.com/iF1HwA4K 14:19, 9 June 2015 (UTC)
Okay, great! Yaron Koren (talk) 14:50, 9 June 2015 (UTC)

Show on select on Multiple-instance templates[edit | edit source]

Hello!

I would like to ask the experts how can I use "show on select" when using multiple-instance templates.

If I use "show on select" it this way, it does not work

{{{for template|DescripciondelaRuta|multiple}}}
{| 
| {{{field|DuracionSeccionONOFF|input type=radiobutton|mandatory|default=Sí|show on select=Sí=>DuracionSeccionDiv}}}
|-
|<div id="DuracionSeccionDiv">{{{field|DuracionSeccion|input type=textarea}}}</div>
|}
{{{end template}}}

But if I remove the multiple instance, then the "show on select" works.

{{{for template|DescripciondelaRuta}}}
...
{{{end template}}}

Any hints?

Thanks in advance!

That should work... what versions of SF and MW are you using? And do you see any JavaScript errors if you look in the "console"? Yaron Koren (talk) 14:47, 9 June 2015 (UTC)
Thanks for your help Yaron, we really appreciate it .
I am using:
- Semantic Forms (Versión 3.2),
- Semantic MediaWiki (Versión 2.1.1),
- MediaWiki 1.22.15
I do not see any error in the console, though I am a begginer in this fields. Here's the link to our form just in case
You've definitely found some sort of bug in Semantic Forms - I'm looking into it. Yaron Koren (talk) 18:58, 15 June 2015 (UTC)
I believe I've fixed this issue, in Git - if you try out the new code, please let me know if it worked for you. Yaron Koren (talk) 19:05, 16 June 2015 (UTC)
I upgraded to the new SemanticForms (3.3) and it worked!, Yaron Koren you are a genius and super hiper helpful. Thanks! 21:40, 20 June 2015 (UTC)
That's great to hear! Yaron Koren (talk) 12:37, 21 June 2015 (UTC)

missing icons in multiple form[edit | edit source]

hi there, using sf 3.2 and mw 1.23.9: the multiple form doesn't show the icons for new instance and delete instance. Same problem in firefox (v38) and ie (v9). What to do? File:Missing icons.png

Is this a public wiki? If not - I'm guessing that this is a file permissions issue. The "delete instance" icon, for instance, should be viewable from the browser at /extensions/SemanticForms/skins/SF_remove.png in the wiki directory, like here. Can you see it on your wiki? If not, you probably need to make one or more of those directories world-readable. Yaron Koren (talk) 12:57, 15 June 2015 (UTC)
Thanx for your advise; we use a central directory, were we save all extensions to simplify administration, because we have a lot of wikis on our server. I've made a directory extensions/SemanticForms/skins and put the .png into - works. Very fine.
Is it possible, that you use absolute path instead of relative path, to fetch the icons? Maybe you can change it, it might be more comfortable to administrate extensions for lots of wikis. Thank you.
No, the icons are already included with a relative path, from the file /skins/SemanticForms.css. Yaron Koren (talk) 17:20, 15 June 2015 (UTC)

Special Pages: Create Template...[edit | edit source]

Hi Yaron - I'm finding that when I try to create a template, the properties combobox will populate only for the first field, but the succeeding ones do not. Is there a "fix" for this? Thanks again for all your work with Semantic Forms. Dmlddsoms (talk) 15:16, 13 June 2015 (UTC)

What do you see in the additional ones? Yaron Koren (talk) 12:58, 15 June 2015 (UTC)
The combo-box is empty upon drop down, whereas in the first field, it's completely populated. Dmlddsoms (talk) 14:22, 16 June 2015 (UTC)
What versions of SF, MW and SMW are you using? And do you see any error messages in the JavaScript "console"? Yaron Koren (talk) 18:29, 16 June 2015 (UTC)
MW 1.23.9, SB 1.9.2, SMW 1.9.2 SF 2.7. I'm going to claim ignorance on the JavaScript "console"...Dmlddsoms (talk) 01:46, 20 June 2015 (UTC)
Ah, you're using the version of Semantic Forms from Semantic Bundle. I don't know if I can help with that - it's an old version. You could always upgrade SF manually... or just wait for the next SB. Yaron Koren (talk) 12:36, 21 June 2015 (UTC)
Ok, thanks.Dmlddsoms (talk) 13:22, 23 June 2015 (UTC)

Create a form with multiple input fields[edit | edit source]

Hey, like I wrote above, I would like to create a forminput with multiple input fields. I want to do
that because our workers always mess up the form Name and put in to many spaces 
or delete the commas. I hope you understand what I mean, if not I try to explain it better with this:
Currently our Forminput looks like this
{{#forminput:Installation|70|Installation: Ort,Projektname,Rechner1}}
and after that comes the rest of the form.
Now this is only one input row, and I want three input rows where each contains a part of the title.
Ort:
Projektname:
Rechner:
If it stays like this our workers keep messing up the title names and sometimes the names are full of underlines.
Sorry for my bad english, if there is something not clear I try my best to edit it.

So, this is what I already wrote on the Semantic Mediawiki Talk Page but they sent me over here. They also said I should try the info Tag but somehow I cant get it to work.

When I put this in my code: {{{info|page name=Installation: <Installation[Ort]> <Installation[Projektname]> <Installation[Rechner]>|add title=Installation erfassen|edit title=Installation bearbeiten}}}

It only prints out what is in the first bracket: page name=Installation: <Installation[Ort]> <Installation[Projektname]> <Installation[Rechner]>

Hopefully someone can help me out with this problem.

Make sure that you are going to the form with #formlink, not #forminput - that might be the issue. Alternatively, instead of the whole page name formula thing, you could try the AssembleFormLink extension - it's still experimental, but it is what you're asking about. Yaron Koren (talk) 12:53, 18 June 2015 (UTC)

New Features[edit | edit source]

Hi Yaron,

I’m very excited about SF 3.x. In combination with SMW and MediaWiki this is the most powerful knowledge management platform in the world. Thank you very much for your enthusiastic engagement.

I would like to ask you about some ideas:

  • What about free2use parameters in forms? I.e. one could pass them to the form with query string=par1=val1 and so on. This would be very helpful for flexibilization and will reduce the number of forms needed.
  • In SMW there is a significant difference beetween the notation [[device::server,client,notebook]] and [[device::server]], [[device::client]], [[device::notebook]].
For most of the users is it to difficult to discern, that this requires different requests, like {{#ask: [[device::~*client*]]}} using the first notation vs. {{#ask: [[device::client]]}} using the second.
What about a field type, which can take a comma separated list of values and save them in the second notation?
  • #autoedit is a great feature; can you give it a new function like user or usergroup with which one can restrict the access to change values?
Hi - it's great that you like the system! I wish more people shared your opinion. :)
For #1 - I doubt that's doable. Remember that everything in a form has to go into a template - and those are even less flexible.
For #2 - do you know about #arraymap?
For #3 - a nicer solution might be to use the #ifgroup function from the RightFunctions extension, to only display the #autoedit button in the first place if the user belongs to the right group. Yaron Koren (talk) 14:03, 24 June 2015 (UTC)
Thanks for your quick support and hints, i'll try it next days.
For #1 - i only need it calling the form with #formlink or #forminput, maybe this will be doable?
Sorry, I don't understand. Yaron Koren (talk) 00:13, 26 June 2015 (UTC)
Ok, i'll try to explain:
{{#forminput: form=hardware|link text=new hardware item|query string=hardware[type]=printer&department=personal management&typeList=listOfPrinterTypes}}
{{#forminput: form=hardware|link text=new hardware item|query string=hardware[type]=clients&department=north-west-branch&typeList=listOfClientTypes}}
in both cases i use the form named hardware; the (free2use) parameter typeList should be used in values from property={{{typeList}}}
so it is possible to give the form different list types depending from the value of typeList
Second example:
same like above with another free2use parameter called typeDescription. Serves the user an information about correct data capturing for the defined type.
I tried it using the values you can give to the form with query string; in the example above using {{#ifeq: hardware[type] ...}}, but this doesn't work.
Ah, that makes more sense. I'm still not sure I fully understand, but - perhaps either "show on select" or "values dependent on" could help with this? Yaron Koren (talk) 14:08, 26 June 2015 (UTC)
  1. Right, show on select can help, but every used div must be content of the form;
  2. Right, but i tried to use values dependent on several times without success... It tried it with the example on discourseDB, too; even without success... :-(

SF Upgrade Errors..[edit | edit source]

Hi Yaron,

I upgraded SF and am getting errors on Edit with Form of existing pages, not with adding new.

Error is:

           ext.semanticforms.main: Error: Module ext.semanticforms.main has failed dependencies
           Prevent this page from creating additional dialogues

Dmlddsoms (talk) 13:56, 24 June 2015 (UTC)

There's a problem with multiple-instance templates that's happening for some people; I hope to have it fixed soon. Yaron Koren (talk) 14:04, 24 June 2015 (UTC)
Ok, thanks. Dmlddsoms (talk) 14:12, 24 June 2015 (UTC)

Position of Form Fields and Template resp. to free text[edit | edit source]

Hello,

I am trying to setup a form to create new wikipages. Is it possible to have free text and form fields in a different order than wikipage text and template? What I am trying to do is the following:

Form: Free text input field in between other form fields:

{{{for template|Template}}}
{{{field|...}}}
{{{standard input|free text|...}}}
{{{field|...}}}

Wikipage: Template above the text:

{{Template
|...
}}
My text

However, I get the text above the template. Is it possible to change this?

Thank you for your help!

--82.83.211.13 21:48, 24 June 2015 (UTC)

No, I don't think you can have a free text input displayed between two fields of the same template. If you really wanted that kind of display, perhaps you could use CSS or JavaScript in some way to move the free text display up... Yaron Koren (talk) 19:53, 25 June 2015 (UTC)
Okay, thanks all the same! I'll come up with something. --82.83.217.225 21:38, 25 June 2015 (UTC)

Add unique number if user is not logged in[edit | edit source]

Hi everyone!

Is there a way to add a unique number to the page title only when the user is not logged in?

I use a form to let users add a rating for certain items. Currently, I have the following code at the top of the form to create the page name (passing the user (which is either the user name or "anonymus" if not logged in) and the item to be reviewed):

{{{info|page name=<Review[User]>/Review/<Review[Item]> <unique number;start=1>}}}

However, I only want to add the unique number if the user is not logged in.

As the help page stated that parser functions can be used in the "page name", I tried something like this (using the MyVariables extension, where CURRENTLOGGEDUSER returns either the user name or an empty string):

{{{info|page name=<Review[User]>/Review/<Review[Item]> {{#if: {{CURRENTLOGGEDUSER}}||<unique number;start=1>}}}}}

But when trying to save a new review I get an error stating that the page "..._}" cannot be saved. So I guess the if statement does not get resolved correctly...

Is there any other way to achive what I planned to do? Thanks! --145.253.178.241 12:48, 25 June 2015 (UTC)

If you remove "start=1", the unique number will only show up if the title is a duplicate. Maybe that's a good enough solution? Yaron Koren (talk) 19:59, 25 June 2015 (UTC)
Thanks for your suggestion. The aim was to prevent at least logged-in users from giving multiple reviews for the same item. I think that would still not work after removing the "start=1" . --145.253.178.241 06:49, 26 June 2015 (UTC)

Set a field value silently when using form for editing [Solved][edit | edit source]

I'm trying to set a field to a known value when editing. I can do this easily when the form creates a new page with the default= option. However when using a different form to edit the article I can no longer do this (default= for a hidden field only seems to work on page creation). I tried setting the field as mandatory|values=myknownvalue|hidden but this doesn't have an effect either. I ended up making a normal mandatory field declaration with one value for values=. This has the desired effect except that I'd rather it not be displayed in the form! Ideas? - Lbillett (talk) 19:25, 3 July 2015 (UTC)

Ok, by the time I finished articulating my problem, I think I found a workaround. If you wrap the field tag in a <div style="display: none;">{{{field|fieldname|values=knownvalue|mandatory}}}</div> it will hide the whole input field but the form will set the field as specified. move along! - Lbillett (talk) 19:25, 3 July 2015 (UTC)

Dropdown Box?[edit | edit source]

I used to have a code that allowed you to pick a category from a dropdown box. This was with MediaWiki 1.19.4 and Semantic Forms 2.5.2 It looked like this:

{{{field|1|mandatory|input type=category|top category=2015 Logs|height=200|hideroot|use dropdown}}}

I'm working on a new wiki installation now, and it's my understanding that the category input type disappeared with Semantic Forms 2.7. I can use tree, but can't find any documentation about dropdowns. Did dropdowns also disappear? Is there a way to replicate what I was doing with this older installation?

--Aekki99 (talk) 23:40, 10 July 2015 (UTC)

Ah, "use dropdown", I forgot about that. I think the answer is no, unfortunately. Yaron Koren (talk) 19:32, 12 July 2015 (UTC)
This is my super duper sad face. Alas! Maybe it will show up in a future update. Thanks for the reply! --Aekki99 (talk) 22:31, 16 July 2015 (UTC)
That is sad... what's wrong with the "tree" input? Yaron Koren (talk) 15:43, 17 July 2015 (UTC)

Show on select on Multiple-instance templates ==> Edit with form[edit | edit source]

Hello !

I use "show on select" on multiple-instance templates and it does not work when I try to edit a page with the form (no problem during the creation of the page or when I remove the "multiple" parameter). My form allows to create recipes with multiple steps and the user has to choose a type of media on a dropdown with "show on select" :

{{{for template|Step|label=Step|add button text=New step|multiple}}}

{| class="formtable"
! Type: 
| {{{field|Type|mandatory|input type=dropdown|values=Screenshot,Video,Code|default=Screenshot|show on select=Screenshot=>screenshot;Video=>video;Code=>code}}}
|}

<div id="screenshot">
{| class="formtable"
! Screenshot: 
| {{{field|Image|uploadable}}}
|}
</div>

<div id="video">
{| class="formtable"
! Service : 
| {{{field|Service|input type=dropdown|values=youtube, dailymotion, vimeo, asciinema, slideshare, ted, teachertube|default=youtube}}}
|- 
! Video ID : 
| {{{field|Video}}}
|}
</div>

<div id="code">
{| class="formtable"
! Code : 
| {{{field|Code|input type=textarea}}}
|}
</div>

{{{end template}}}

When I try to edit with the form, the first instance appears normally (only the good "div" is displayed) but I can't change the type of media. On the following instances, all the "div" are displayed and I can't hide them changing the type of media.

I am using: - Semantic Forms 3.3 - Semantic MediaWiki 2.2.1 - MediaWiki 1.25.1

I don't see any JS error on the console.

Any help would be great !

Thank you in advance.

Try upgrading to SF 3.3.1 - the problem may or may not be fixed there. Yaron Koren (talk) 19:15, 16 July 2015 (UTC)
Thank you for the quick response, unfortunately the upgrade did not fixed the problem.
Alright. What do you mean by "I can't change the type of media"? You can't select a different value in the dropdown? Yaron Koren (talk) 15:42, 17 July 2015 (UTC)
I can select a different value but it has no effect on the hiding or displaying of the fields. You can see a page I have created with my form here. Feel free to edit it with form. Here are the form and the template.
Oops! It looks like the fix I put in actually made things worse for your wiki, due (I think) to your PHP configuration. I just checked in another fix; could you try updating again? Yaron Koren (talk) 14:56, 20 July 2015 (UTC)
Updating done, I don't see any change. Again, thanks for your help. Eliott B 17:35, 20 July 2015 (UTC)
Okay, thanks. That change did improve things but there was still an issue, which I think I fixed just now. Could you try updating again and see if it works now? Yaron Koren (talk) 17:20, 20 July 2015 (UTC)
It seems to work perfectly! Many thanks!
That's great! Yaron Koren (talk) 23:44, 21 July 2015 (UTC)
And thanks for this, whoever you are! I wasn't aware that "show on select" was even possible with multiple instances of a template. Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 08:23, 22 July 2015 (UTC)
It even works with fields holding templates. Great! Eliott B 09:29, 22 July 2015 (UTC)
This was indeed a pretty big issue and thank you for your fix of 2015-07-20 which indeed works! The nasty thing about this bug was not just not showing the other fields on the second edit of the page but to also automatically removing the contents added via the multi-instance template in the first place at the time of the second edit. Thus I suggest doing a new release at your convenience rather earlier than later. Cheers --[[kgh]] (talk) 16:02, 27 July 2015 (UTC)
That's a good idea. Yaron Koren (talk) 17:48, 27 July 2015 (UTC)

Show on select on does not work on Semantic Forms 2.7[edit | edit source]

Hello!

Just to let you know that Show on Select does not work in Semantic Forms 2.7

I upgraded to version 3.3 and it did work immediately

Semantic Forms 2.7 is the version used in SemanticBundle 1.9.2 which was the last version in 10 july 2015

Good luck and thanks for this great extension

Duplicate checkbox ID using Tree Input[edit | edit source]

Bit of a difficult one to explain - I have a long tree and I've discovered that adding some entries early in the listing will automatically select later entries and submit these. Having used Google Chrome element inspector it seems to be because the hidden checkboxes IDs are being repeated further down the page (and if one checkbox in the tree is clicked it will automatically check its partner further down). I don't know how this works - I've looked at the source and there is an ins element that might have something to do with it... Any help, suggestions or otherwise appreciated.

Are there any duplicate values in the tree? Is this part of a multiple-instance template? And what version of SF are you using? Yaron Koren (talk) 23:43, 21 July 2015 (UTC)
thanks for your quick response. There are no duplicate values (the values are academic disciplines from the JEL classification scheme with unique prefixes). There is a multi instance template elsewhere in the form but not here. 3.3.1.
Well, there go all of my theories. :) Is this on a public wiki? If not, could you try to replicate the problem on a public wiki, like http://scratchpad.referata.com? Yaron Koren (talk) 01:10, 22 July 2015 (UTC)
I've put it at http://scratchpad.referata.com/wiki/Special:FormEdit/Study/Example_Study_(2015). The problematic field is JEL Disciplinary Classification(s). If you select for example A12: Relation of Economics to Other Disciplines it will automatically also add K2: Regulation and Business Law, seemingly because their corresponding checkboxes share an ID. A13 in turn shares with K3 etc etc. Please ignore the errors which I don't think are relevant (I use another extension to be able to embed links in my tool tips). Also, I assume you don't need to see my templates since the issue seems to correspond with how the form sends the data. Maybe I'm doing something totally wrong (hope so, that would be progress to know it!). I've also tested on a previous version of the wiki from a backup and the issue has been around from earlier SMW/MW/Semantic Forms versions. Really appreciate your help, and your fantastic free software.
Think I've found the issue and a fix - in SF_TreeInput.php (line 157) $key_id = str_replace( ' ', '-', "$key_prefix$index" ); means that you end up with checkbox ids of the form chb-Source[Discipline]key11113. However, that means a clash between, what are, for example, essentially key 1,1,1,1,3 and key 1,1,11,3. To resolve I've replaced that line with $key_id = str_replace( ' ', '-', "$key_prefix-$index" ); so each individual index is hyphenated, like chb-Source[Discipline]key-1-1-1-1-3 and chb-Source[Discipline]key-1-1-11-3. Please let me know if this is a sensible change or if it will break my wiki (I'm not an expert coder by any means)!
What you're saying seems reasonable... on the other hand, I can't actually see the problem you're talking about, on the Scratchpad wiki. Can you? (K2 is already pre-selected on that page you created, but you probably knew that.) Yaron Koren (talk) 13:15, 22 July 2015 (UTC)
I've deselected it now so no checkbox is selected. If you try to select just A12 and either save then edit or hit show changes you'll see that K2 is added as well. I'm not that keen to go out of step with the shipped Semantic Forms code, so would be great if you could acknowledge that I'm not going mad (or that I am doing something wrong which is more likely!). Thanks!

Oh, I get it - it's not that the other checkbox gets checked right away, it's that its value shows up when you submit the form. Well, both your diagnosis and your fix were spot on - I just checked in your fix, and it seems to be working a lot better now. Thank you! Yaron Koren (talk) 19:14, 22 July 2015 (UTC)

Create page based off form input[edit | edit source]

I am working on a project where it would be really useful to have the form set the target page based off user input in the form. Is there a way I can do that? Nunabas (talk) 15:07, 22 July 2015 (UTC)

What do you mean by "based off"? Yaron Koren (talk) 18:27, 22 July 2015 (UTC)
If I wanted to pick say a date, and location the resulting page title would be location/date as the page title, and then be able to fill in a template for the page content. Nunabas (talk) 10:23, 23 July 2015 (UTC)
Have you seen this section? It may be what you're looking for. Yaron Koren (talk) 13:50, 23 July 2015 (UTC)