[interchange-cvs] interchange - heins modified lib/Vend/Form.pm

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Thu Nov 14 14:26:23 2002


User:      heins
Date:      2002-11-14 19:24:53 GMT
Modified:  lib/Vend Form.pm
Log:
* Add conditional_text option for fillin_combo type (which supports a common
  survey question type). It only shows the input text if there is more than
  a one-letter/digit response to the question.

Revision  Changes    Path
2.22      +11 -4     interchange/lib/Vend/Form.pm


rev 2.22, prev_rev 2.21
Index: Form.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Form.pm,v
retrieving revision 2.21
retrieving revision 2.22
diff -u -r2.21 -r2.22
--- Form.pm	8 Nov 2002 17:27:24 -0000	2.21
+++ Form.pm	14 Nov 2002 19:24:53 -0000	2.22
@@ -1,6 +1,6 @@
 # Vend::Form - Generate Form widgets
 # 
-# $Id: Form.pm,v 2.21 2002/11/08 17:27:24 mheins Exp $
+# $Id: Form.pm,v 2.22 2002/11/14 19:24:53 mheins Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -37,7 +37,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.21 $, 10);
+$VERSION = substr(q$Revision: 2.22 $, 10);
 
 @EXPORT = qw (
 	display
@@ -555,11 +555,17 @@
 			$template = '<br>';
 			if(! $opt->{rows} or $opt->{rows} > 1) {
 				$template .= q(<textarea rows="{ROWS|2}" wrap="{WRAP|virtual}");
-				$template .= q( cols="{COLS|60}" name="{NAME}">{ENCODED}</textarea>);
+				$template .= q( cols="{COLS|60}" name="{NAME}">);
+				$template .= '{ENCODED}'
+					unless $opt->{conditional_text} and length($opt->{value}) < 3;
+				$template .= q(</textarea>);
 			}
 			else {
 				$template .= qq(<input TYPE="text" size="{COLS|40}");
-				$template .= qq( name="{NAME}" value="{ENCODED}">);
+				$template .= qq( name="{NAME}" value=");
+				$template .= '{ENCODED}'
+					unless $opt->{conditional_text} and length($opt->{value}) < 3;
+				$template .= qq(">);
 			}
 		}
 		$addl = attr_list($template, $opt);
@@ -1230,6 +1236,7 @@
 		$opt->{type} = 'combo';
 		$opt->{textarea} = 1;
 		$opt->{reverse} = 1;
+		$opt->{conditional_text} = 1;
 	}
 	elsif($type =~ /^reverse_combo[ _]*(?:(\d+)(?:[ _]+(\d+))?)?/i) {
 		$opt->{rows} = $opt->{rows} || $1 || 1;