create new tag
, view all tags

Form Values from Search

In our Wikis, we wanted to have KeyWord-based classification. However, users used to forget to add the keyword topic to the webform definition. They asked why that couldn't be automatic -- putting a formatted search inside the table that defines the webform, such as the example below (disregard the space between the % and the SEARCH -- I wrote it like this to prevent it to be interpreted as a search):

| KeyWords | checkbox | 5
    | % SEARCH{"Kw.*" regex="on" scope="topic" format="$topic," nosearch="on" nosummary="on" nototal="on"}%  
    | Incluce as many keywords as you like to classify this topic |

This seems to work: when the page gets rendered, it shows the various keyword topics (we conventioned they would start with the prefix "Kw", but any other convention would do).

However, when you add the webform to the topic, the %SEARCH...% directive comes out verbatim, instead of the topic names. We made a small patch to the getFormDefinition subroutine in Form.pm to fix this:

                # Handle values coming from a search -- MarcoCarnut 020425
                # Add this at line 60
                if ($vals =~ /%SEARCH/oi) {
                   # When you add this, delete the space after the % below
                   $vals =~ s/% SEARCH{(.*?)}%/&TWiki::handleSearchWeb($1)/geo;
                } else {
                   $vals =~ s/^\s*//go;
                   $vals =~ s/\s*$//go;
                   $vals =~ s/"//go; # " would break parsing off META variables

instead of just the

               $vals =~ s/^\s*//go;
               $vals =~ s/\s*$//go;
               $vals =~ s/"//go; # " would break parsing off META variables

that was there.

After that, we got the results as we expected: the mere act of creating a keyword topic makes it appear in the WebForm. The same idea can be used in a lot variety of other scenarios.

-- MarcoCarnut - 05 May 2002

See also HandleCommonTagsInFormDef

-- PeterThoeny - 25 Jul 2002

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2002-07-25 - PeterThoeny
  • 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.