Tags:
create new tag
view all tags

TWiki Forms don't Expand Variables

TWikiForms don't seem to expand "Set" variables.

Test case

  • In a TWikiForm do:

Name Type Size Values Tooltip message
Foo checkbox 3 A, B, C The Foo Variables

A, B, C does not expand to "A, B, C"

Environment

TWiki version: 01 December 2001
TWiki plugins:  
Server OS: Linux RH 7.1 i386
Web server: Apache
Perl version: 5.6.0
Client OS: Linux RH 7.1 i386
Web Browser: Galeon 1.13

-- TWikiGuest - 13 Feb 2002

This is actually the current spec, so I changed the TopicClassification to FeatureBrainstorming. Variables do get expanded in the latest Alpha, but only for topic view, not edit. See example Sandbox.TextAreaFormTest, the form has a text field that contains %WIKIWEBMASTER% (info@twikiPLEASENOSPAM.org) and a check box containing %FOOVAR% (Alpha, Beta, Gamma):

TestTextAreaForm
TopicClassification: Test
Textfield: info@twikiPLEASENOSPAM.org
Textareafield: long text long text long text
Foo: Alpha, Beta, Gamma

Both variables get expanded correctly in view. However, when you edit you see just one edit box instead of three because %FOOVAR% gets expanded after the checkbox handling.

The form meta data contains the variable names, not their values. E.g. the meta data for form field Foo is: %META:FIELD{name="Foo" title="Foo" value="%FOOVAR%"}%

At work we do need this spec: We defined a ItemToDo application with priorities %LOW%, %MEDIUM% and %HIGH%. Those get rendered in different colors.

I also see your point, using variables to drive the checkboxes would give some additional flexibility. What application do you have?

-- PeterThoeny - 16 Feb 2002

See also HandleCommonTagsInFormDef and FormValuesFromSearch.

We have an incompatibility problem in case we change the spec to expand variables before handing it over to the TWiki Form in edit mode. Why: Radio buttons, selectors and check boxes get initialized based on the form field meta data when you edit a topic that has a form. Example:

  • Assume that we have a form definition with radio buttons that has values with variables, for example Sandbox.ItemToDoForm has radio buttons with colors.
  • Currently the form field meta data have the variables stored in unexpanded form, for example, Sandbox.TestFormFieldWithVariables has %META:FIELD{name="Testing" title="Testing" value="%RED%Red%ENDCOLOR%"}%.
  • If we change the spec to expand the variables we have the issue that editing a topic with the old format (unexpanded variables), the radio buttons, selectors and check boxes do not get initialized correctly to the meta data form field values. This is because we are comparing %RED%Red%ENDCOLOR% with <font color="red">Red</font> and they do not match.

Any idea how to solve this problem?

-- PeterThoeny - 25 Jul 2002

I have some ideas, but I'm not sure I like them.

  1. We could add a tag of some kind that signifies that the next thing should be processed while reading the form definition. Think of it as the opposite of <nop>. Maybe <pre> or <expand>. By using a new tag to signify the new behavior, all the old forms are left intact.
  2. Another idea is to use quoting rules like shells use. For example in bash if you want to pass a "\n" as just that (a slash and the letter n), you need to quote the slash by adding a preceeding slash (\\n). The idea is that during the first translation pass the quoting is handled leaving behind a now valid set of tokens. The major drawback I see with this approach is that existing forms must be updated when the new functionality is added. It also requires the user to grok the number of transaction passes and when they are invoked.

-- JimPatterson - 25 Jul 2002

On the compatibility issue, I prefer the first of Jim's solution. The question is, what is a intuitive syntax?

  1. Enclose the whole form definition (or variables in form value) in %EXPAND{...}% variable. This variable does nothing in normal view (just returns its content). If placed in a form definition, it gets expanded by the form definition handler.
  2. Enclose the whole form definition in <expand> ... </expand> tags.
  3. Or, what else?

-- PeterThoeny - 14 Sep 2003

I was wondering if any progress has been made with this as Iam coming across the same problem trying to generate a dropdown list of users based on TWIKI user topics available in the main topic. Again the dropdown list is empty rather then the results of a formatted search as I am assuming thatthe TWIKI search variable is not being expanded.

-- AndyBush - 29 Apr 2005

See discussion in DynamicFormOptionDefinitions about features that will do what you're seeking here - that are about to be incorporated in DakarRelease.

-- LynnwoodBrown - 30 Apr 2005

DynamicFormOptionDefinitions has been in Dakar for a few days now...

-- ThomasWeigert - 30 Apr 2005

Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2005-04-30 - ThomasWeigert
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.