create new tag
, view all tags

Bug: Cannot pass form values in URL to bin/edit without also passing text

TWiki supports the initialization of form fields that are passed in through query parameters. However, this only happens when there also is text passed into the query. However, there seems to be no reason why we should limit this feature in such manner.

Actually, the situation is slightly more confusing:

  • If text is passed by the query, then all form field values are taken from the query, and no form field values are taken from the form definition
  • If a formtemplate was passed by the query and no text was passed, then the form field values are taken from the form definition

However, we might want the following to happen: some form field values are passed in by the query and some are taken from the form definition. The tricky thing is, of course, to resolve the meaning of the empty string. Currently omitting to pass a field by the query and passing an empty string means the same thing: override what is in the form definition. (Of course we could easily differntiate, as we can see whether a parameter was actually passed or not.)

What precisely is the spec here?

Test case

Try (don't save the result)




As you can see, only the second variant (where text is passed into the edit script) initializes the form field.


TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  

-- ThomasWeigert - 13 Feb 2005

Impact and Available Solutions

Follow up

A quick fix to solve this problem would be

*** lib/TWiki/Form.pm   7 Feb 2005 02:36:23 -0000   1.7
--- lib/TWiki/Form.pm   14 Feb 2005 00:01:10 -0000
*** 336,343 ****
              $value = &TWiki::Prefs::getPreferencesValue($fieldName);
!         if( ($getValuesFromFormTopic ) ) {
!             my $tmp = $fieldInfo[0] || "";
!             $value = &TWiki::handleCommonTags( $tmp, $topic );
          $value = "" unless defined $value;  # allow "0" values
     my $extra = ($attributes =~ /M/) ? "*" : "";
--- 335,342 ----
              $value = &TWiki::Prefs::getPreferencesValue($fieldName);
!         if( ((! defined $value)  && ($type !~ "^checkbox") && $getValuesFromFormTopic ) ) {
!             my $tmp = $fieldInfo[0];
!             $value = &TWiki::handleCommonTags( $tmp, $topic ) if (defined $tmp);
          $value = "" unless defined $value;  # allow "0" values
     my $extra = ($attributes =~ /M/) ? "*" : "";

-- ThomasWeigert - 14 Feb 2005

Intuitively, the order of priority of field initialization should be as follows, I think: For a given form field

  1. If a value was passed in by a corresponding query parameter, that value should be taken, else
  2. If there is a templatetopic and there is a corresponding field value, that value should be taken, else
  3. If there is an initialization value defined in the formtemplate, that value should be taken, else
  4. The field value should be empty.

The above patch implements this algorithm.

Question: Should an existing topic be able to be modified via any of these mechanisms? Guess: Query parameters should override existing topic, but not templatetopic or formtemplate.

-- ThomasWeigert - 14 Feb 2005

Very helpful fix, thank you very much smile - the passing of parameters without text worked alright in Beijing, but apparently got out of scope in Cairo.

I don't have much to add regarding your question, I second your guess.

I believe this fix is ready for a testcase and a merge.

-- SteffenPoulsen - 23 Feb 2005

Fix record

I merged the fix in DevelopBranch r3684, though a testcase is still required; anyone? Please?

-- CrawfordCurrie - 23 Feb 2005

Crawford, could you please teach me how to write a testcase in conformance with the develop branch rules, and I will do so. So sorry for not being up to speed yet... I read the document but am not totally clear. Can you point me to an example?

-- ThomasWeigert - 23 Feb 2005

The front page of the testcases web is the documentation; any of the testcase topics can be used as templates. http://develop.twiki.org/~develop/cgi-bin/view/TestCases/TestCaseAutoTagFromTags?raw=on might be a good exemplar. Please generate a TestCaseAuto (using the automation) if at all possible! If you need scripting, then the only way to do that at the moment is using the unit test framework. An example you could follow there is test/unit/CommentTests.

-- CrawfordCurrie - 23 Feb 2005


Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2005-10-19 - CraigTobias
  • 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.