From: Robert M. <xol...@ho...> - 2010-03-08 19:01:52
|
Hi Yaron, You are correct as well... I meant during editing the data for a new page, sorry. The scenario is as follows: 1. I open a form to create a new page: The default value is filled in, if the field is not populated otherwise (e.g. formlink) 2. Still on the form I clear the field which got a default (so it is empty again) 3. The I save the form. SF looks again through the fields and sees that there is an empty field which has a default available --> the default value is set again on that field I think that that happens quite rarely, but I came across that behaviour by incident during testing my form. Robert From: Yaron Koren Sent: Monday, March 08, 2010 7:11 PM To: Robert Michel Cc: sem...@li... Subject: Re: [SMW-devel] Semantic forms suggestion (FAO Yaron Koren) Hi, I didn't quite understand the issue - the "default" value isn't used when editing a page, only when creating a new page. Or are you saying that "default" also shows up for you when you're editing existing pages? -Yaron On Mon, Mar 8, 2010 at 12:13 PM, Robert Michel <xol...@ho...> wrote: 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! |