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:
- Form field default
- Template topic
- 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