create new tag
, view all tags

Form Variable Questions

1. Why does the TWiki spec.. ir.. specify that only forms that are included when a new topic is created get their variables expanded?

Our case at work was we created a bunch of procedure documents. Then someone came up with the bright idea of adding a form to them for approval of the procedures. When we wanted to include default values in the forms, we couldn't. It would only work for new topics that had the form included.

I changed this with the following edit:

In Edit.pm, line 67:

  my $getValuesFromFormTopic = ( ( $formTemplate ) && ( ! $ptext ) );
replaced with
  my $getValuesFromFormTopic = ($formTemplate ? 1 : 0);              

2. With the FormAddOns patch, the ability to have default values included with a form definition were added. However, when you include the topic in the WebTopicEditTemplate, ALL default values overwrite default values from the form definition. Why not just overwrite only form elements that get values specified in the WebTopicEditTemplate, otherwise, use the defaults from the form definition.

3. Another problem is variable expansion within the WebTopicEditTemplate and comparing it to the form definition. Our example was we wanted to include a label field with % WIKIUSERNAME% as the default value for the field.

This caused a problem because the variable got expanded in the WebTopicEditTemplate before it actually was called when a user went to edit a page. In otherwords, the label got defaulted to my user name ( since I created the WebTopicEditTemplate ) and anyone else who tried to use the form on any pages got my username instead.

So I tried to put the variable % WIKIUSERNAME% in the WebTopicEditTemplate as a default value for the label. This caused an issue as well. The issue was the same as has been discussed in other form areas before in that the actual variable name % WIKIUSERNAME% was stored in the metadata when a user saved the form, rather than expanded version.

I fixed this behaviour with the following code change:

In Edit.pm, line 222:

my $formText = &TWiki::Form::renderForEdit( $webName, $topic, $form, $meta, $query, $getValuesFromFormTopic, @fieldDefs );
   my $formText = &TWiki::Form::renderForEdit( $webName, $topic, $form, $meta, $query, $getValuesFromFormTopic, @fieldDefs );
   $formText = &TWiki::handleCommonTags( $formText, $topic );

I'm more unsure about the implications of this change, but so far it hasn't aversely effected anything.

Any comments on whether or not these changes are bad or if I'm going to end up breaking something in the process would be appreciated.

-- StevenHajducko - 03 Jun 2005

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2005-06-05 - RandyKramer
  • 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.