You are here: Foswiki>Tasks Web>Item9082 (04 Jun 2010, PhilippLeufke)Edit Attach

Item9082: FormPlugin + CommentPlugin: post-processing of form data stopped working

pencil
Priority: Urgent
Current State: Closed
Released In: 1.0.9
Target Release: n/a
Applies To: Extension
Component: FormPlugin
Branches:
Reported By: PhilippLeufke
Waiting For:
Last Change By: PhilippLeufke

Preface

This bug is related to Item1990 which got fixed recently

Anyway, I decided to file a new bug for this issue, as the resulting problem is different now, although the origin can probably be found in the abovementioned bug.

Description

In our corporate Wiki we have several forms which use the combination of FormPlugin and CommentPlugin to generate text strings for topics which are read out by e.g. ActionTrackerPlugin or HolidaylistPlugin.

While these forms work nicely with a rather old version of FormPlugin (foswiki-formplugin_090317-197_all.deb), where bug Item1990 was not yet present, the most recent version is troublesome with the following form data post-processing:

Short example

Have a look at the HolidaylistPlugin syntax:
From - Until - Who - Occasion - Smilie
Only the fields "From" and "Who" are mandatory. If the others are not present, the " - " separator is also omitted. And this is where we used to use form field post-processing by means of hidden fields:

%FORMELEMENT{
name="Until"
type="date"
dateformat="%d %b %Y"
size="9"
title="End Date:"
disabled="%IF{"$WIKINAME='WikiGuest'" then="on"}%"
}%

%FORMELEMENT{
name="FormattedUntil"
type="hidden"
default=" - $Until"
condition="$Until=nonempty"
}%

Then, the TMPL:DEF{OUTPUT:holiday_data} line will rather use "URLPARAM{"FormattedUntil"}" rather than " - URLPARAM{"Until"}". This way we only write the parameter in the OUTPUT line, if it exists and omit the separator " - " when it's not.

Now, in the recent version, the URLPARAM data gets redirected in a way, that the hidden form field doesn't get expanded before redirection. So the result is that we get the unexpanded " - $Until" in the new entry rather than something like " - 04 Jun 2010".

Fixing the issue

In the full examples I show below, you see that it's very important for us to be able to do this post-processing of user-entered form data. If you have any suggestion how to workaround this issue, e.g. by any sort of delayed execution, please tell me.

Personally. I feel that this is a bug and not a feature, as it breaks existing applications.

Full examples

Holiday list

%TMPL:DEF{PROMPT:holiday_data}%
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
%STARTFORM{
name="holiday_data"
method="POST"
action="save"
topic="%WEB%.%TOPIC%"
anchor="NewData"
}%
<input type="hidden" name="comment_action" value="save" />
<input type="hidden" name="comment_type" value="holiday_data" />
<input type="hidden" name="comment_templatetopic" value="%WEB%.%TOPIC%"  />
%FORMELEMENT{
name="Who"
type="text"
title="Who:"
validate="nonempty"
default="%FORMFIELD{"FirstName" topic="%WIKIUSERNAME%"}%"
mandatory="on"
hint="First name or like written in HolidayList"
}%
%FORMELEMENT{
name="From"
type="date"
dateformat="%d %b %Y"
size="9"
title="Start Date:"
disabled="%IF{"$WIKINAME='WikiGuest'" then="on"}%"
validate="nonempty"
mandatory="on"
}%
%FORMELEMENT{
name="Until"
type="date"
dateformat="%d %b %Y"
size="9"
title="End Date:"
disabled="%IF{"$WIKINAME='WikiGuest'" then="on"}%"
}%
%FORMELEMENT{
name="Occasion"
type="text"
title="Occasion for holidays (optional):"
beforeclick="Holidays"
validate="nonempty"
}%
%FORMELEMENT{
name="Icon"
type="text"
beforeclick="8-)"
hint="Enter a [[System.SmiliesPlugin][Smilie]], like e.g. =:-)= or an [[System/DocumentGraphics][Icon]], like e.g. % ICON{wip} % (without the spaces)"
title="Smilie or Icon (optional):"
}%
%FORMELEMENT{
name="comment_from_date"
type="hidden"
default="$From"
condition="$From=nonempty"
}%
%FORMELEMENT{
name="comment_to_date"
type="hidden"
default=" - $Until"
condition="$Until=nonempty"
}%
%FORMELEMENT{
name="comment_who"
type="hidden"
default=" - $Who"
condition="$Who=nonempty"
}%
%FORMELEMENT{
name="comment_occasion"
type="hidden"
default=" - $Occasion"
condition="$Occasion=nonempty"
}%
%FORMELEMENT{
name="comment_icon"
type="hidden"
default=" - $Icon"
condition="$Icon=nonempty"
}%
%FORMELEMENT{
name="action33"
type="submit"
buttonlabel="Add my dates"
disabled="%IF{"$WIKINAME='WikiGuest'" then="on"}%"
}% %IF{"$WIKINAME='WikiGuest'" then="<em>Log in to add your dates</em>"}%
%ENDFORM%
</div>
</div>
%TMPL:END%
%TMPL:DEF{OUTPUT:holiday_data}%   * %URLPARAM{"comment_from_date"}%%URLPARAM{"comment_to_date"}%%URLPARAM{"comment_who"}%%URLPARAM{"comment_occasion"}%%URLPARAM{"comment_icon"}%
%POS:AFTER%%TMPL:END%

Action tracker (To-do list)

(Submitting data to a topic called ToDoList)
%TMPL:DEF{PROMPT:action_tracker_data}%
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
%STARTFORM{
name="action_tracker_data"
action="save"
method="POST"
topic="%WEB%.ToDoList"
anchor="Action_Tracker_Data"
}%
<input type="hidden" name="comment_action" value="save" />
<input type="hidden" name="comment_type" value="action_tracker_data" />
<input type="hidden" name="comment_templatetopic" value="%WEB%.%TOPIC%"  />
%FORMELEMENT{
name="Who"
type="dropdown"
options="%SEARCH{"form.name ~ '*UserForm' AND NOT Status = 'retired'" web="Main" nosearch="on" type="query" excludetopic="Web*, *Template" order="topic" nonoise="on" separator=", " format="$topic"}%, ---, %SEARCH{"*" topic="*Group" excludetopic="WorkGroups, NobodyGroup" web="Main" type="regex" nonoise="on" separator=", " format="$topic" }%"
size="3"
title="Action for:"
default="%WIKINAME%"
hint="Person or group name."
}%
%FORMELEMENT{
name="Notify"
type="dropdown"
options=" , %SEARCH{"form.name ~ '*UserForm' AND NOT Status = 'retired'" web="Main" nosearch="on" type="query" excludetopic="Web*, *Template" order="topic" nonoise="on" separator=", " format="$topic"}%, ---, %SEARCH{"*" topic="*Group" excludetopic="WorkGroups, NobodyGroup" web="Main" type="regex" nonoise="on" separator=", " format="$topic" }%"
size="3"
title="Persons to notify in case of changes:"
default="%WIKINAME%"
hint="Person or group or leave blank."
}%
%FORMELEMENT{
name="Due"
type="date"
dateformat="%Y-%m-%d"
size="9"
title="Due date:"
default="%CALC{$FORMATTIME($TIMEADD($TODAY(),1,week),$year-$month-$day)}%"
disabled="%IF{"$WIKINAME='WikiGuest'" then="on"}%"
hint="Format: yyyy-mm-dd; empty if undefined yet."
}%
%FORMELEMENT{
name="Priority"
type="dropdown"
options="high,normal,low"
default="normal"
title="Priority of the task:"
}%
%FORMELEMENT{
name="Summary"
type="text"
size="60"
title="Short summary"
validate="nonempty"
mandatory="on"
}%
%FORMELEMENT{
name="Task"
type="textarea"
rows="5"
cols="60"
title="Task description:"
validate="nonempty"
mandatory="on"
}%
%FORMELEMENT{
name="due_comment"
type="hidden"
default="due=$Due"
condition="$Due=nonempty"
}%
%FORMELEMENT{
name="who_comment"
type="hidden"
default="who=$Who"
condition="$Who=nonempty"
}%
%FORMELEMENT{
name="notify_comment"
type="hidden"
default="notify=$Notify"
condition="$Notify=nonempty"
}%
%FORMELEMENT{
name="priority_comment"
type="hidden"
default="priority=$Priority"
condition="$Priority=nonempty"
}%
%FORMELEMENT{
name="summary_comment"
type="hidden"
default="$Summary"
condition="$Summary=nonempty"
}%
%FORMELEMENT{
name="task_comment"
type="hidden"
default="$Task"
condition="$Task=nonempty"
}%
%FORMELEMENT{
name="action"
type="submit"
buttonlabel="Add this task"
disabled="%IF{"$WIKINAME='WikiGuest'" then="on"}%"
}% %IF{"$WIKINAME='WikiGuest'" then="<em>Log in to add your dates</em>"}%
%ENDFORM%
</div>
</div>
%TMPL:END%
%TMPL:DEF{OUTPUT:action_tracker_data}%%AC%NOP%TION{%URLPARAM{"who_comment"}% creator="%WIKIUSERNAME%" %URLPARAM{"due_comment"}% %URLPARAM{"notify_comment"}% %URLPARAM{"priority_comment"}% summary="%URLPARAM{"summary_comment"}%" }%%URLPARAM{"task_comment"}%%END%NOP%ACTION%
%POS:AFTER%%TMPL:END%

-- PhilippLeufke - 31 May 2010

Please try if version 1.6.2 solves the problem for you.

-- ArthurClemens - 31 May 2010

Now everything seems to work again! Great! Thanks!

-- PhilippLeufke - 04 Jun 2010

ItemTemplate edit

Summary FormPlugin + CommentPlugin: post-processing of form data stopped working
ReportedBy PhilippLeufke
Codebase 1.0.9
SVN Range
AppliesTo Extension
Component FormPlugin
Priority Urgent
CurrentState Closed
WaitingFor
Checkins FormPlugin:5129a583e08a FormPlugin:1d7758e2c3b7
TargetRelease n/a
ReleasedIn 1.0.9
Topic revision: r6 - 04 Jun 2010, PhilippLeufke
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy