create new tag
, view all tags
Initialization of forms from the "values" field is currently rather inconsistent. Witness:

Field type Initialized?
text No
text area No
radio Yes, to first value in list
checkbox No
select Yes, to first value in list, unless the list contains an empty value, in which case it is not initialized

I have added a patch to bin/edit and lib/TWiki/Form.pm that always initializes the form to the first entry in the list of values, except for a checkbox, where initialization could be to any number of values (which would require an additional field). For fields of type text and textarea, the value may contain commas (i.e., the whole list is interpreted as the default value).

In other words, the patches below change the table above to

Field type Initialized?
text Yes, to complete list
text area Yes, to complete list
radio Yes, to first value in list
checkbox No
select Yes, to first value in list

See also FormDefaultNotWorkingForTextField.

The patches below are for the Athens release. I'll take a look at the Beijing release later.

-- ThomasWeigert - 17 Apr 2003

We can take that into the core.

I did not initialize form field values in the form because typically there is a form / template topic pair, where the form values are initialized in the template topic.

For what cases do you need the form values initialized?

Also, does your patch work for template topics and form field values supplied to the edit script? E.g. form field values passed as parameters to the edit script overload template topic values; template topic values overload form field values.

-- PeterThoeny - 17 Apr 2003

To your point regarding form/template pairs, you are certainly correct in that this is often the way forms are initialized. However, for other uses of forms, e.g.,

this is not the case. (Of course, one could make it part of the specification of forms that they are initialized from a template topic only, but that might cause overhead for users. If so, it should be documented in TWikiForms. In addition, we still need to somehow cover the situation of changing or adding forms.)

I will verify the interaction between template topic and parameters. I take it that the order of overriding would be:

  1. Form field default
  2. Template topic
  3. Values as parameters
(where 1 is the lowest precedence).

-- ThomasWeigert - 17 Apr 2003

PeterThoeny, I looked through bin/edit and lib/TWiki/Form.pm to see check on your question regarding initialization of a form from query parameters supplied to the edit script. Indeed, my patch is preventing the fields to be initialized from any query parameters passed in. I shall study this some more; I must confess I was not aware of that you could be passing in field values through parameters, but looking at Form::fieldVars2Meta this is quite clear.... Are there any places where the system makes use of the ability to pass form field values to the edit script this way?

-- ThomasWeigert - 18 Apr 2003

Field values passed as parameters: At work I use that for different kind of apps like initialize fields of notebook systems, news channels in a news portal etc. Here at TWiki.org it is used to initialize a FeatureBrainstorming vs FeatureEnhancementRequest vs BugReport etc, all based on the same template topic and form. It is also used to initialize all fields of the TWikiInstallations form.

-- PeterThoeny - 18 Apr 2003

PeterThoeny, thanks. One more question.... Form::fieldVars2Meta is also used in the save and preview scripts, and thus, theoretically, one could pass field values as parameters also into those scripts. It seems to me that this is actually an unwanted effect, as that would allow you to change the value of what is being written into a form without going through the edit or preview cycle. Do you know whether this is by design or whether it would be ok to remove the capability of passing fields by parameters to those scripts?

-- ThomasWeigert - 18 Apr 2003

Yes, it is safe to assume that only edit needs the setting by parameter, not preview and save.

-- PeterThoeny - 19 Apr 2003

The patch in FormValuesPassedInURLRequireText together with Cairo realize this FeatureEnhancementRequest.

-- ThomasWeigert - 14 Feb 2005

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff Form.pm.diff r2 r1 manage 0.9 K 2003-04-19 - 23:15 ThomasWeigert patch for lib/Twiki/Form.pm
Unknown file formatdiff edit.diff r2 r1 manage 0.8 K 2003-04-19 - 20:49 ThomasWeigert patch for bin/edit
Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2008-09-15 - TWikiJanitor
  • 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-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.