Hi,
if you add that in you next version, could you also add some more logic to not
parse the default on submit or on edit?
In my case I use a modified SF_FormPrinter.inc to put an unique ID in my
default. When looking at the "normal default", it is evaluated on every action
(edit, preview, submit), but only assigned if the value is empty. This would
lead for me to a unique ID spent on these occasions. (I assumed that a default
has only to be assigned once during initial edit of a page and not again
later..., at least that is what I need)
I put in the following code:
...
elseif ($sub_components[0] == 'default') {
if( (!$form_submitted) && (!$source_is_page)) {
$strsub_component;
$strsub_component = str_replace( "{{!}}", "|",
$sub_components[1] );
$default_value =
$wgParser->recursiveTagParse($strsub_component);
}
}...
this allows also for parser functions. (I put in the {{!}}-replacement because
I did not know how to resolve templates, perhaps an additional replaceVariables
helps here? )
I think (I do not remember correctly) I also added the "&& !$form_submitted)"
part in the actual assignment:
...
if ($cur_value == null && !$form_submitted) {
// set to default value specified in the form, if it's there
$cur_value = $default_value;
}
...
If that part is not there, SF has some "strange" (or better: unexpected)
behaviour):
When a field with a default value is cleared on edit, the default value is
again assigned during submit of the page (which I thought to be not correct for
me)
Just my 2 cents...
Thanks Yaron!
From: Yaron Koren
Sent: Monday, March 08, 2010 3:31 PM
To: Connell, Nick (CIOK)
Cc: semediawiki-devel@lists.sourceforge.net
Subject: Re: [SMW-devel] Semantic forms suggestion (FAO Yaron Koren)
Hi,
Yes, making the "default=" parseable is a reasonable idea, and it'll probably
go into the next version.
In this case, though, maybe it would be better to just have that name/link
coded directly in the template, instead of settable via template/form fields,
given that you always want it to have a certain structure?
-Yaron
On Mon, Mar 8, 2010 at 6:11 AM, Connell, Nick (CIOK) <nick.conn...@fao.org>
wrote:
[SemanticForms v1.8.8]
I found it useful in a form to have this syntax in a hidden field:
{{{field|HasDetail|default={{SUBJECTPAGENAME}}_Detail }}}
so I could effectively auto-generate a page name for additional details
linked to a given page without the user being able to alter the name.
To enable this I tweaked SF_FormPrinter.inc, changing line 538 to:
$default_value = $wgParser->replaceVariables($sub_components[1]);
so that it parsed & substituted variable values embedded in the default value
clause.
Cheers!
Nick
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel