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

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Wed Dec 11 22:19:01 2002


User:      heins
Date:      2002-12-12 03:18:57 GMT
Modified:  lib/Vend Form.pm
Log:
* Add intrinsic "file" widget type.

* Allow setting of a widget class directly without using "extra".

Revision  Changes    Path
2.23      +22 -3     interchange/lib/Vend/Form.pm


rev 2.23, prev_rev 2.22
Index: Form.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Form.pm,v
retrieving revision 2.22
retrieving revision 2.23
diff -u -r2.22 -r2.23
--- Form.pm	14 Nov 2002 19:24:53 -0000	2.22
+++ Form.pm	12 Dec 2002 03:18:57 -0000	2.23
@@ -1,6 +1,6 @@
 # Vend::Form - Generate Form widgets
 # 
-# $Id: Form.pm,v 2.22 2002/11/14 19:24:53 mheins Exp $
+# $Id: Form.pm,v 2.23 2002/12/12 03:18:57 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.22 $, 10);
+$VERSION = substr(q$Revision: 2.23 $, 10);
 
 @EXPORT = qw (
 	display
@@ -110,6 +110,15 @@
 		.
 		qq(>{APPEND})
 		,
+	file =>
+		qq({PREPEND}<input type="file" name="{NAME}" value="{ENCODED}")
+		.
+		qq({COLS?} size="{COLS}"{/COLS?})
+		.
+		qq({EXTRA?} {EXTRA}{/EXTRA?})
+		.
+		qq(>{APPEND})
+		,
 	text =>
 		qq({PREPEND}<input type="text" name="{NAME}" value="{ENCODED}")
 		.
@@ -525,7 +534,7 @@
 	$opt->{name} = "X$name";
 	my $ejs = ",1" if $opt->{rows} > 1;
 	$opt->{extra} .= qq{ onChange="addItem(this.form['X$name'],this.form['$name']$ejs)"}
-            unless $opt->{extra};
+            unless $opt->{extra} =~ m/\bonchange\s*=/i;
 	my $tbox = '';
 	my $out = dropdown($opt, $opts);
 
@@ -593,7 +602,10 @@
 	my $price = $opt->{price} || {};
 
 	my $select;
+#::logDebug("template for selecthead: $Template{selecthead}");
+#::logDebug("opt is " . ::uneval($opt));
 	my $run = attr_list($Template{selecthead}, $opt);
+#::logDebug("run is now: $run");
 	my ($multi, $re_b, $re_e, $regex);
 #::logDebug("select multiple=$opt->{multiple}");
 	if($opt->{multiple}) {
@@ -1098,6 +1110,13 @@
 	$opt->{value} = $opt->{default} if ! defined $opt->{value};
     $opt->{encoded} = encode($opt->{value}, $ESCAPE_CHARS::std);
     $opt->{value} =~ s/&#91;/\[/g if $opt->{enable_itl};
+
+	if($opt->{class}) {
+		$opt->{extra}	= $opt->{extra}
+						? qq{$opt->{extra} class="$opt->{class}"}
+						: qq{class="$opt->{class}"}
+						;
+	}
 
 	# Action taken for various types
 	my %daction = (