@@ -1929,11 +1982,12 @@ sub handleCommonTags { my( $text, $theTopic, $theWeb, @theProcessedTopics ) = @_; - + my ( $meta, $dummyText ); # PTh 22 Jul 2000: added $theWeb for correct handling of %INCLUDE%, %SEARCH% if( !$theWeb ) { $theWeb = $webName; } + ( $meta, $dummyText ) = &TWiki::Store::readTopic( $theWeb, $theTopic ); my @verbatim = (); $text = takeOutVerbatim( $text, \@verbatim ); @@ -1954,6 +2008,7 @@ &TWiki::Prefs::handlePreferencesTags( $text ); handleInternalTags( $text, $theTopic, $theWeb ); + $text =~ s/%FORMFIELD{(.*?)}%/&getFormField( $theWeb, $theTopic, $meta, $1)/ge; $text =~ s/%TOC{([^}]*)}%/&handleToc($text,$theTopic,$theWeb,$1)/ge; $text =~ s/%TOC%/&handleToc($text,$theTopic,$theWeb,"")/ge; @@ -2702,5 +2793,45 @@ $result =~ s|\n?\n$||o; # clean up clutch return "$head$result"; } + +# ========================= +sub getFormField +{ + my( $web, $topic, $meta, $args ) = @_; + my $text = ""; + my $prefix = ""; + my $suffix = ""; + my $alttext = ""; + + my $formField = extractNameValuePair( $args ); + $prefix = extractNameValuePair( $args, "prefix" ); + $suffix = extractNameValuePair( $args, "suffix" ); + $alttext = extractNameValuePair( $args, "alttext" ); + + my %form = $meta->TWiki::Meta::findOne( "FORM" ); + if( %form ) { + my $name = $form{"name"}; + my @fields = $meta->find( "FIELD" ); + my $found = 0; + foreach my $field ( @fields ) { + my $title = $field->{"title"}; + if( $title eq $formField ) { + $found = 1; + $text = $prefix . $text; + my $value = $field->{"value"}; + $text .= $value; + $text .= $suffix; + } + } + if (!$found) { + $text .= $alttext; + } + } + $text = getRenderedVersion( $text, $web ); + return $text; +} 1;