Extension talk:Page Forms

input type=category/categories don't work with the mandatory attribute
Hi everyone. For some reason the attribute "input type=category/categories" doesn't become mandatory even though I label it with the mandatory label: What am I doing wrong?

--Gregra (UTC) 20:55, 4 August 2009 (UTC)


 * You've uncovered a bug in Semantic Forms; it'll be fixed in the next version. Yaron Koren 16:07, 6 August 2009 (UTC)
 * thanks Yaron, looking forward for the next version.--Gregra 12:38, 14 August 2009 (UTC)


 * Hi, it was already released, two days ago. Yaron Koren 12:52, 14 August 2009 (UTC)

CSS For Forms (Changing the Style of Your Forms)
Hello. First I would like to say I really like your extension, great job. Ok, I wanted to apply different custom CSS for some forms I create. I was looking through some of the files, but am finding it difficult to find where the actual html code with any classes (for style) etc is being generated. Big picture: I would like to be able to query the name of the form called for and according to which name (form), apply a custom CSS file. Any ideas or files I should look at?

Thanks so much. -Felix. 8/4/09


 * Hi, thanks. Unfortunately, what you want to do is impossible. Instead, you should use different CSS classes for each form, then define them all in one location (I'd recommend the "MediaWiki:Common.css" wiki page). If all you want to change is the look of the table in each, you can just substitute the class "formtable" in the default form with a different name for each form, then proceed that way. Yaron Koren 16:12, 6 August 2009 (UTC)


 * Thanks so much for the reply. I will take a look at your idea right now. Also, I found out that what the code does is simply create a template which is inserted every time you create a new form. So what seems to work is create my forms, then edit the template page that is generated (adding styles there) and every page where the 'form'/'table' is transposed changes automatically. No CSS files needed, well, I'm doing in-line style insertions on each template. Thanks! -Felix 8/5/09


 * Just an update. Yaron, thanks so much what you suggested, perfectly matches what I needed along with what I had found out. So basically:

Solution: Changing the Style of your Forms
 * 1) Create Your Forms
 * 2) *This creates a template which you can navigate to by going to .../Template:
 * 3) *Please Note: The Template is a table, ie. What is being transcluded is a table, so table rules apply
 * 4) Change the Look one of two ways:
 * 5) Edit the Template page
 * 6) *After navigating to the Template page, edit the page and add any div's or in line style css to change the appearance of your forms.
 * 7) *Make sure you pay attention to the 'include' and 'noinclude' tags
 * 8) Edit the CSS
 * 9) *Navigate to the .../Mediawiki:Common.css page
 * 10) **Now add your custom css to the page
 * 11) *Now go to your form's template page and change its class to the one you created.

Hope this helps everyone. -Felix (NSotres)8/5/09

Preload data into multiple-instance templates?
Is there a way to preload data into multiple-instance templates via the URL query string?

When I try setting it as would set the single-instance templates (i.e. templatename[fieldname]=value) I always get

Warning: array_key_exists [function.array-key-exists]: The second argument should be either an array or an object in C:\xampp\htdocs\w\extensions\SemanticForms\includes\SF_FormPrinter.inc on line 574 --F.trott 07:15, 6 August 2009 (UTC)


 * That looks like a bug in SF; I'll look into it. Yaron Koren 17:11, 6 August 2009 (UTC)


 * Somewhat fixed in version 1.8.2, I believe - unfortunately, you still can't set a preload value for a field within a multiple-instance template (I don't know if this was ever possible), but at least it doesn't give an error message. Yaron Koren 15:57, 12 August 2009 (UTC)

Not installing namespaces
I'm not getting any errors, but my Special:AllPages does not show any of the new namespaces that should exist (like Property). When I use the Special:CreateProperty page for example, it just adds the property as a root page off the standard namespace.

Any idea what could cause this? I notice that it doesn't have any namespaces that are not listed in my LocalSettings.php $smwgNamespaceIndex = 115; include_once("$IP/extensions/SemanticMediaWiki/includes/SMW_Settings.php"); enableSemantics('telarapedia.com'); include_once('extensions/SemanticForms/includes/SF_Settings.php'); $wgExtraNamespaces = array( 	100 => 'Portal',	110 => 'NameSpace2',	111 => 'NameSpace3', ); Hope someone can figure out what is happening. :) MW 1.15.1
 * 1) updates below:


 * My guess is that it's due to your namespace-rearranging; it might be that you can fix it just by putting the $smwgNamespaceIndex line after the SMW include. Yaron Koren 17:19, 6 August 2009 (UTC)


 * I did end up fixing it after re-arranging my namespace, so thank you for that suggestion. I didn't do what you suggested, but what I did was remove that array, and then add each namespace on its own line...although I don't see why that should have mattered.  I'll try the Index one on another wiki. :)

--Ciovala 21:47, 7 August 2009 (UTC)

Setting field to pagename in template (property question)
I did some searching, and the recommendation was to set it to in the template. However, if you do this, don't you then lose the property feature? For example, let's say I had a property setup of type page. This is nice when I setup a form and field to refer to the property. How can I still use a property type when I'm resorting to using { as opposed to a custom variable (which obviously I then have to just ask the user to type the name in exactly as it was on the initial form 'submit' page)?


 * Why not something like Has title:: ? Yaron Koren 14:53, 10 August 2009 (UTC)

autocompletion problem
Hi, I don’t know if the problem is a bug or not, but I have a problem with the kilo separator. Imagine a number, say 54785 (raw format). Autocompletion show us this number "54 785" and if you click on this value, the associated field contains "54&amp;nbsp;785". As a consequence, the Special:RunQuery doesn’t found a match.

I run a French Médiawiki. To solve this problem, I changed "smw_kiloseparator" => "&amp;nbsp;" to "smw_kiloseparator" => "" in languages\SMW_Messages.php.

--LeLorrain 11:40, 10 August 2009 (UTC)

Italian translation almost completed
This is the italian translation used for my wiki http://web.rif2009.org/mediawiki. Thanks everybody! Maybe the translation is not perfect, but certainly it's better than the orginal one! :P /** Italian (Italiano) * @author Alessandro Rosà */ $messages['it'] = array(	'semanticforms-desc'                => 'Form per aggiungere e modificare dati semantici',	'specialpages-group-sf_group'        => 'Form semantici',	'createproperty'                     => 'Crea una proprietà',	'sf_createproperty_linktoform'       => 'Questa proprietà ti collegherà alla pagina che usa il seguente form:',	'sf_createproperty_allowedvalsinput' => 'Se vuoi che questa proprietà possa ammettere solo determinati valori, inserisci una lista di valori ammessi, separati da virgole (se un valore presenta una virgola, sostituiscilo con mettendoci un backslash davanti in questo modo "\,"):',	'sf_createproperty_propname' => 'Nome proprietà:',	'sf_createproperty_proptype' => 'Tipo:',	'templates'                          => 'Template',	'sf_templates_docu'                  => 'Il seguente template già esiste nel wiki.',	'sf_templates_definescat'            => 'Definisci categorie:', 'createtemplate'                    => 'Crea un nuovo template', 'sf_createtemplate_namelabel'       => 'Nome template:', 'sf_createtemplate_categorylabel'   => 'Categorie definite attraverso template (opzionale):', 'sf_createtemplate_templatefields'  => 'Campi template', 'sf_createtemplate_fieldsdesc'      => 'Per richiamare i campi di questo template non è necessario usare il loro nome, semplicemente inserisci il numero d\'\' indice del campo (per esempio 1, 2, 3, etc) al posto del nome.', 'sf_createtemplate_fieldname'       => 'Nome campo:', 'sf_createtemplate_displaylabel'    => 'Parola da mostrare:', 'sf_createtemplate_semanticproperty' => 'Proprietà semantiche:', 'sf_createtemplate_fieldislist'     => 'Questo campo può contenere una lista di valori, separati dalle virgole', 'sf_createtemplate_aggregation'     => 'Aggregazione', 'sf_createtemplate_aggregationdesc' => 'Per vedere, fra le pagine che usano questo template, tutte le pagine che hanno una proprietà che punta a questa pagina, specifica la appropriata proprietà qui sotto: ', 'sf_createtemplate_aggregationlabel' => 'Titolo per la lista:', 'sf_createtemplate_outputformat'    => 'Formato di output:', 'sf_createtemplate_standardformat'  => 'Predefinito', 'sf_createtemplate_infoboxformat'   => 'Infobox nella parte destra', 'sf_createtemplate_addfield'        => 'Aggiungi Campo', 'sf_createtemplate_deletefield' 	 => 'Cancella', 'sf_createtemplate_addtemplatebeforesave' => 'Devi aggiungere minimo un template a questo form prima di poterlo salvare.', 'forms'                             => 'Form', 'sf_forms_docu'                     => 'I seguenti form già esistono nel wiki.', 'createform'                        => 'Crea un nuovo form', 'sf_createform_nameinput'           => 'Nome form', 'sf_createform_nameinputdesc'       => '(la convenzione vuole che il nome del form venga assegnato dopo la popolazione del template principale ):', 'sf_createform_template'            => 'Template:', 'sf_createform_templatelabelinput'  => 'Nome da visualizzare del template (opzionale):', 'sf_createform_allowmultiple'       => 'Permetti multiple (nessuna) istanze di questo template nella pagina creata', 'sf_createform_field'               => 'Campo:', 'sf_createform_fieldprop'           => 'Questo campo definisce le proprietà  $1, di tipo $2.', 'sf_createform_fieldproplist'       => 'Questo campo definisce una lista di elementi che ha la proprietà $1, di tipo $2.', 'sf_createform_fieldpropunknowntype' => 'Questo campo definisce la proprietà $1, di tipo non specificato.', 'sf_createform_inputtype'           => 'Tipo input:', 'sf_createform_inputtypedefault'    => '(predefinito)', 'sf_createform_formlabel'           => 'Nome da visualizzare form:', 'sf_createform_hidden'              => 'Nascosto', 'sf_createform_restricted'          => 'Riservato (solo utenti di tipo sysop possono modificarlo)', 'sf_createform_mandatory'           => 'Obbligatorio', 'sf_createform_removetemplate'      => 'Rimuovi template', 'sf_createform_addtemplate'         => 'Aggiungi template:', 'sf_createform_beforetemplate'      => 'Template precedente:', 'sf_createform_atend'               => 'Alla fine:', 'sf_createform_add'                 => 'Aggiungi', 'sf_createform_choosefield'         => 'Scegli campo da aggiungere', 'createcategory'                    => 'Crea una categoria', 'sf_createcategory_name' 			 => 'Nome categoria:', 'sf_createcategory_defaultform'     => 'Form predefinito:', 'sf_createcategory_makesubcategory' => 'Falla diventare una sottocategoria di una categoria già presente (opzionale):', 'createclass'                       => 'Crea una classe', 'sf_createclass_docu'               => 'Aggiungi tutte le informazioni qui per creare le proprietà, template, form e le categoria per una singola classe. Per ulteriori opzioni invece vai alla pagina $1.', 'sf_createclass_allowedvalues'      => 'Valori permessi', 'sf_createclass_listofvalues'       => 'Lista di valori', 'sf_createclass_leavefieldblank'    => 'Se il nome del campo è lo stesso del nome della proprietà. non puoi lasciarli vuoti.', 'sf_createclass_missingvalues'      => 'Campi richiesti non completamente riempiti.', 'sf_createclass_success'            => 'Proprietà, template, form e categorie verranno create.', 'addpage'                           => 'Aggiungi pagina usando un form', 'sf_addpage_badform'                => 'Errore: nessun form è stato trovato alla pagina $1', 'sf_addpage_docu'                   => 'Inserisci il nome della pagina qui, per esser modificata con il form \'$1\'. Se questa pagina esiste già, verrai indirizzato ad un form che ti permette di modificarla. Altrimenti, verrai indirizzato ad un nuovo form che ti permetterà di aggiungere la nuova pagina.', 'sf_addpage_noform_docu'            => 'Inserisci il nome della pagina qui, e selezione il form con cui la vuoi modificare. Se questa pagina esiste già, verrai indirizzato ad un form che ti permette di modificarla. Altrimenti, verrai indirizzato ad un nuovo form che ti permetterà di aggiungere la nuova pagina.', 'addoreditdata'                     => 'Aggiungi o modifica', 'adddata'                           => 'Aggiungi dati', 'sf_adddata_title'                  => 'Aggiungi $1: $2', 'sf_adddata_badurl'                 => 'Questa è la pagina per modificare i dati inseriti. Devi specificare per entrambi il nome del form e indirizzo della pagina nello spazio dell \'\ URL; dovrebbe risultare una cosa di questo tipo \'Special:AddData?form=&lt;form name&gt;&target=&lt;target page&gt;\', oppure \'Special:AddData/&lt;form name&gt;/&lt;target page&gt;\'.', 'sf_adddata_altforms'               => 'Invece puoi aggiungere una pagina con uno dei seguenti form già creati:', 'sf_adddata_altformsonly'           => 'Per favore seleziona una dei seguenti form per aggiungere questa pagina:', 'editdata'                          => 'Modifica dati', 'sf_formedit'                       => 'Modifica con un form', 'sf_formcreate'                     => 'Crea con un form', 'sf_viewform'                       => 'Visualizza form', 'sf_editsource'                     => 'Modifica sorgente', 'sf_editdata_title'                 => 'Modifica $1: $2', 'sf_editdata_badurl'                => 'Questa è la pagina per modificare i dati inseriti. Devi specificare per entrambi il nome del form e indirizzo della pagina nello spazio dell \'\ URL; dovrebbe risultare una cosa di questo tipo \'Special:EditData?form=&lt;form name&gt;&target=&lt;target page&gt;\', oppure \'Special:EditData/&lt;form name&gt;/&lt;target page&gt;\'.', 'sf_editdata_morethanoneform'       => "Attenzione: Più di un form predefinito è stato definito per questa pagina.", 'sf_editdata_formwarning'           => '\'\'\'Attenzione:\'\'\' Questa pagina esiste già, ma non usa questo form.', 'sf_editdata_remove'                => 'Rimuovi', 'sf_editdata_addanother'            => 'Aggiungi un\'\altro', 'sf_editdata_none'                  => 'Nessuno', 'runquery'                          => 'Esegui query', 'sf_runquery_badurl'                => 'Devi specificare il nome del form nell\'\ URL; l\'\ URL dovrebbe risultare una cosa di questo tipo \'Special:RunQuery/&lt;form name&gt;\'.', 'sf_runquery_title'                 => 'Esegui query: $1', 'sf_runquery_additionalquery'       => 'Query aggiuntive',

'sf_formerrors_header'              => 'Ci sono stati degli errori nel form di input; vedi qui sotto', 'sf_blank_error'                    => 'Non può esser vuoto', 'sf_bad_url_error'                  => 'Deve avere un formato dell\'\URL corretto, completo anche di \'http\'', 'sf_bad_email_error'                => 'Deve avere un formato per di indirizzo email valido', 'sf_bad_number_error'               => 'Dev\'\esser un numero valido', 'sf_bad_integer_error'              => 'Dev\'\esser un\'\intero valido', 'sf_bad_date_error'                 => 'Dev\'\esser una data valida', 'uploadwindow'                      => 'Finestra di upload',

// content messages 'sf_property_isproperty'            => 'Questa è una proprietà di tipo $1.', 'sf_property_linkstoform'           => 'Ti collegherà alle pagine che usano il form $1.', 'sf_property_allowedvals'           => 'NaN I valori permessi per questa proprietà sonos:', 'sf_template_docu'                  => 'Questo è il template \'$1\'. Dovrebbe esser chiamato con il seguente formato:', 'sf_template_docufooter'            => 'Modificare la pagine per vedere il testo del template.', 'sf_form_docu'                      => 'Questè è il form \'$1\'. Per aggiungere una pagina con questo form, inserire il nome della pagina qui sotto; se la pagina con il nome indicato è già esistente, verrai inviato al form di modifica della pagina.', 'sf_form_freetextlabel'         => 'Testo libero', 'sf_category_hasdefaultform'        => 'Questa categoria usa il form $1.', 'sf_category_desc'                  => 'Questa è la categoria $1.', 'sf_blank_namespace'                => 'Principale', );


 * This is great, thanks a lot. For future additions and changes to this, please use http://translatewiki.net, if possible. Yaron Koren 13:18, 12 August 2009 (UTC)

Dummies guide to Semantic Forms
Is there a "Dummies guide to Semantic Forms" anywhere, e.g. a simple step-by-step 'howto' guide?

I am not a dummy but I cannot afford the time to get my head around how to make this thing work.

All I want to do is make a fairly template to make pages.

I am finding it is far too difficult to work out how to make it 'just work'.

Thanks ... --Nonegiven108 06:56, 13 August 2009 (UTC)


 * Did you see this? If not, that might help. Yaron Koren 15:40, 13 August 2009 (UTC)

Improved Preview
I cooked up an improved preview functionality. It does not reload the whole page and - more importantly - the user is not pushed back to raw wikitext input (which is pretty much unacceptable round here :-) ) but keeps the form.

What do you have to do?
 * 1) Copy the javascript code to somewhere where it is executed, e.g. the MediaWiki:Common.js page of your wiki
 * 2) Include a   in your form, i.e. a preview button (doh)
 * 3) Include a    at the spot in your form where you want the preview to appear (Without this step you get the plain old preview, i.e. that is still available if you need it.)

Problems/Caveats:
 * relies on Javascript and Ajax
 * only tested with IE6, and not too deep either
 * obviously, semantic data that depends on the page being saved is not rendered correctly; but that's not different from the behaviour of the standard preview

You can find the source code at smw.referata.com/wiki/User:F.trott/ajaxFormPreview.js.

Thanks go to Alex Smotrov on Wikipedia for his  ajaxPreview.

--F.trott 10:28, 13 August 2009 (UTC)


 * UNBELIEVABLE!! It works! I set it up on the SMW Community Wiki, where you put the source code (anyone can try it out here); and it works in Firefox, too, which I assume means it's an all-purpose solution. I don't think the fact that it relies on Javascript and Ajax is a problem - forms already use Javascript quite a bit. This is really going to change a lot, I think. Thanks for coming up with this idea! Do you mind creating a "tip" for it on the wiki? If it's a problem, I can do that. Yaron Koren 15:23, 13 August 2009 (UTC)


 * Alas... I just looked at it again, and there's one problem: if you try out that form, the checkbox inputs always show up in the preview as if all of them are checked. Do you have any idea if that can be fixed? It seems like a rather minor detail to block this whole feature. Yaron Koren 04:09, 14 August 2009 (UTC)


 * Hmm, right now I just take any form element and send it on without any checks. I'll look into it next week. Another problem occurs if there is javascript in the previewed page (e.g. timelines, google maps, ...): It is just not executed. I don't have any idea right now how this can be handled. We might also have a css problem along these lines. As a fallback I think about sending some parameter (maybe named "preview") so the template would know that it is in preview mode and could deal with it (e.g. if the "preview" parameter is set just omit problematic stuff from the output). I could include that as a feature anyway. I'll write the tip (including some dire warnings :-) ) sometime next week, too. --F.trott 18:33, 14 August 2009 (UTC)


 * Alright. As far as the tip, it might not be necessary, since if those issues are resolved I'm thinking strongly of adding this Javascript directly into SF, and adding the corresponding HTML change into the SF documentation. Yaron Koren 18:59, 14 August 2009 (UTC)


 * Ok, the script checks now, if the element is a radiobutton or a checkbox and in these cases only sends the data if the box is checked. (Don't know, if that's the right thing to do, but it seemed to work, whereas sending "false" for unchecked boxes didn't, so...)


 * Javascript remains a problem. I had hoped to somehow trick an iframe into executing it. But I can't set the HTML text directly. Instead I could set a source URL. Alas I don't have one. Right now I don't see a solution to that one short of parsing the HTML and doing an eval on every piece of script. And I'm not sure that that would work.


 * The idea of sending a "Preview" parameter to each template does not work either. I had hoped, just adding the parameter to the POST data would trick the server-side script into adding it to the article text, but no luck there. I could use a pointer which PHP script needs to be adjusted and where. --F.trott 12:33, 18 August 2009 (UTC)

Okay, thanks, it looks like it works perfectly now. It still fails on Referata, but that's just because the old version of the JS is cached, which I don't know how to get rid of. No need for a "tip"; I'll add this Javascript directly into the next version of SF. Thanks again for this code; it should have a big impact. Yaron Koren 20:38, 18 August 2009 (UTC)

Inserting Images
Hi, I just wanted to know if there was a way of inserting images into the form. ie, i want to be able to either fill in a string field or have a drop down menu allow me to select which picture to put in. So that once the page is created, it will display the picture I chose.

I know the template generates semantic code, but is there a way for it to take wikicode and have it be interpreted correctly?

Thanks.

Felix (8/14/09)


 * See the uploading files section. Yaron Koren
 * Hi, thanks yaron, I mustve just missed that.
 * Update: Actually, this functionality just uploads files into the wiki. It does not actually display a picture on the new/edited page by using the form.

-Perhaps I wasn't clear with what I wanted. I want to be able to select an image with a form and have the page I create/edit display that image I selected. Is this possible?


 * I see - you should use "autocomplete on namespace=File" or "...=Image" in the field declaration, depending on what the namespace is called in your version of MediaWiki. Yaron Koren 21:32, 14 August 2009 (UTC)


 * Hmmm.. not sure I follow, wouldn't that be the same as me putting in the wikicode for a picture inside of a string field? I am not sure if that actually works. Thanks for the idea. Ill look into it. Felix 8/17/09

What I've found out:

Assume you have a Template set up as follows: (where Name is a String field)


 * 1) What doesnt work
 * 2) Inserting your standard image wiki code
 * 3) * Name= [[Image:ExPicture.png]] (for example)
 * 4) ** This displays the image but it will also display the property field along with the image as such:
 * 5) *** Name::
 * 6) *** That is to say that you also see the text above along with your image ( is the actual displayed image)
 * 7) *** So you'll see the text "Name::",, and then the text "" displayed.
 * 8) What Semi-Works
 * 9) Adding some extra brackets
 * 10) * if you add a 'caption' (not really how its done) and some closing brackets:
 * 11) ** Name= My Image]][[Image:exPicture.png]]
 * 12) * Now you will NOT see the Property name, but your 'caption' instead as follows:
 * 13) ** My Image ]]
 * 14) *** ie, only the closing brackets show along with your 'caption' (text) and your image
 * 15) However, if you try something like:
 * 16) * Name= My Image]][[Image:exPicture.png]][[
 * 17) * Then the form is messed up.

If you still don't understand, try putting an image using wiki code inside of a form that accepts a String thanks.

Felix 8/18/09


 * Sorry, what? Why so many brackets? And why not make the image caption and image name be two separate template fields? Yaron Koren 18:11, 18 August 2009 (UTC)
 * Updated, hope it makes more sense now.. Felix


 * Hi - yes, semantic properties don't display images correctly. You should instead have something like " [[Image:]] ". Yaron Koren 20:25, 18 August 2009 (UTC)

New 'default' code - 'page' ?
Hi Yaron

I came across a potential feature today - I have to pre-set a text field in a form with the page name by default.

Since I was not able to pass to the  parameter (it shows as 'PAGENAME'), I thought a new default code would be useful in that situation, as in '|default=page'.

My example is in a glossary situation, where I want to assign the page name as a default value for properties such as 'Has preferred label'.

- Laurent


 * You could just have something in the form like "Preferred label (leave blank to use page name)", then an #ifeq call in the template. That way it would work even if the page were later moved. Yaron Koren 18:14, 18 August 2009 (UTC)