Feature Proposal:
Motivation
I’m trying to build an app in 1.1.2 using
DataForms and
EditTablePlugin. (
EditRowPlugin looks promising, but the extension from Foswiki.org does not work with 1.1.2). I have a column in my table containing a radio button. When the user saves the table, I want for certain form properties to be updated (counts of each radio button choice). I can write a perl save handler to do this, but I want to see if I can implement the entire app in Macros.
So first, do you foswiki gurus know of a way that I can solve this problem using macros? If not, I have some ideas about how this could be done. (NOTE: I am a full-time employee and can’t currently contribute code to your project. I intend to ask for dispensation after Foswiki gets more visibility within my company.)
Description and Documentation
See example.
Examples
%ONSAVE{"arbitrary_name" update_form_property="the_sum" render="true"}%
%CALC{"2+2"}%
%ENDONSAVE{"arbitrary_name"}%
When the page is viewed, the content between onsave/endonsave is rendered if render="true". When the page is saved, the content is evaluated and saved in the dataform property called "the_sum". The "arbitrary_name" is just used to match with the end tag like %STARTSECTION% %ENDSECTION%.
Impact
Implementation
--
Contributors: KipLubliner - 13 Mar 2011
Discussion
What makes you say "the extension from Foswiki.org does not work with 1.1.2"? I can't see any reports in Tasks web that would support that assertion.
--
CrawfordCurrie - 14 Mar 2011
Sorry, 1.1.2 comes with
JQueryPlugin 3.75, and when I tried to upgrade it to 4.0, I had two problems: # 4 from
Tasks.Item10392, and
FullCalendarPlugin didn't work. I rolled back the
JQueryPlugin upgrade without investigating further. Perhaps I will be able to try again next week.
--
KipLubliner - 14 Mar 2011
I agree we need some mechanism to do this. Saving the property makes it queryable. Does your use-case require that?
I'd rather we stored the property spec in the DataForm definition. For what it's worth, I created a
dynamiclabel field type, which although doesn't make the calculated value queryable (it is evaluated on every view), might be useful in some cases. You just put the
%CALC{"2+2"}%
(or in %INCLUDE{} of a section that contains it) in the 'values' column of the dataform table.
--
PaulHarvey - 14 Mar 2011
I don't need to query that field but I do need to retrieve the value in
FormattedSearch.
I like your approach of storing the spec in the data form definition, it is much cleaner to put it there.
So to sum up: there are two possible types of dynamic properties: those that need to be evaluated when the topic is viewed, and those that need to be evaluated when the topic is saved. For evaluate-on-save properties, we can achieve far better integration with query search.
Perhaps for the evaluate-on-save properties, the dynamic content can go in a META field instead of directly inside the form definition?
--
KipLubliner - 15 Mar 2011
Have a look at
SetVariablePlugin. It allows to manage a META properties on save. It might fit your use case here.
--
MichaelDaum - 15 Mar 2011
If you just want
$formfield(DynamicField)
in
FormattedSearch, then the
dynamiclabel
I mentioned should do the job. It implements a
renderForDisplay()
method which is called by the
$formfield()
token to expand the field value, taken from an expansion of any macros in the values column in the dataforms table.
--
PaulHarvey - 15 Mar 2011
Michael: Yes it looks like
SetVariablePlugin is exactly what I was asking for
I looked through the source because I wasn't 100% sure. This plugin is very good to look at to start to understand the internals.
Paul: Thanks it's good to know that this is also possible.
--
KipLubliner - 23 Mar 2011
Based on the discussion above I believe this is rejected.
--
CrawfordCurrie - 24 Feb 2012