We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
You are here: TWiki> Support Web>VariableInFormField (30 Nov 2005, CrawfordCurrie)
Tags:
create new tag
, view all tags

Question

Hmmm. I'm trying to formulaicly retrieve form data from another topic using the %FORMFIELD... variable as follows:

%FORMFIELD{ "field name" topic="%MYVAR%" format="$value" }%

When I attempt the above, I get:

" format="$value" }%

How do I get the %MYVAR% value to resolve and correctly pass to FORMFIELD?

(Ultimately, I'm trying to retrieve a formfield value from the current topic's parent topic. Maybe there is another way to do this using FormattedSearch? ? Any help/hints/pointers would be appreciated.)

-- PaulOpitz - 31 Oct 2005

Environment

TWiki version: TWikiRelease04Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Windows XP
Web server: Apache
Perl version:  
Client OS: Windows XP
Web Browser: IE
Categories: Forms

-- PaulOpitz - 01 Nov 2005

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

OK. I figured out a way to do this using a formatted search:

%SEARCH{"$parent" format="$formfield(field to return)" nosearch="on" noheader="on" nosummary="on" nototal="on" expandvariable="on" }%

-- PaulOpitz - 02 Nov 2005

I propose you use a separate topic for your search and include that topic with %INCLUDE% in your template topic. This allows easier switching of the formfield (just change the field to return in the created topic).

-- FranzJosefSilli - 02 Nov 2005

AAArg. Just found that the above wasn't really working...was an artifact of having not much data, yet. Now, with more data I'm getting multiple data returns. So, any ideas for limiting the search to only the parent topic? The parent topic's name is always a part of the child topic's name, so I can parse out the parent topic using "%CALC", but I cannot see how to then use this value to limit either SEARCH or FORMFIELD to look only in the parent topic. I need to be able to completely automate child topic creation so that the end user never needs to edit funky TWiki commands.

-- PaulOpitz - 02 Nov 2005

It would be nice if TopicVarsPlugin worked without unpleasant side effects...

-- AntonAylward - 02 Nov 2005

Well, I finally came up with a search string that does what I need. Falls into the category of "Geez, there's got to be a better way!" but, here goes:

%SEARCH{ "^%BASETOPIC%$" scope="topic" nosearch="on" type="regex" nototal="on" format=" $percntSEARCH{ \".\" topic=\"$parent\" format=\"$dollarformfield(FIELD TO RETURN)\" nosearch=\"on\" nototal=\"on\" }$nop% " }%

-- PaulOpitz - 02 Nov 2005

Note: your original requirement should be OK in DakarRelease? , when it comes.

-- CrawfordCurrie - 30 Nov 2005

 
Topic revision: r9 - 30 Nov 2005 - 17:01:40 - CrawfordCurrie
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback