Date: Saturday November 2, 2002 @ 15:31
Author: matt
Update of /home/cvs/AxKit-XSP-PerForm
In directory ted.sergeant.org:/home/matt/Perl/AxKit-XSP-PerForm
Modified Files:
Changes PerForm.pm
Log Message:
Patch from nachoman
Log:
PR:
Index: Changes
===================================================================
RCS file: /home/cvs/AxKit-XSP-PerForm/Changes,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -u -r1.3 -r1.4
--- Changes 2002/06/11 07:43:00 1.3
+++ Changes 2002/11/02 15:31:46 1.4
@@ -1,5 +1,8 @@
Revision history for Perl extension AxKit::XSP::PerForm.
+1.7
+ - Patch from nachoman to finally properly support single and multiple select
+
1.6
- Removed action from form to allow it to work with Session taglib
Index: PerForm.pm
===================================================================
RCS file: /home/cvs/AxKit-XSP-PerForm/PerForm.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -b -u -r1.11 -r1.12
--- PerForm.pm 2002/06/11 07:43:00 1.11
+++ PerForm.pm 2002/11/02 15:31:46 1.12
@@ -1,4 +1,4 @@
-# $Id: PerForm.pm,v 1.11 2002/06/11 07:43:00 matt Exp $
+# $Id: PerForm.pm,v 1.12 2002/11/02 15:31:46 matt Exp $
package AxKit::XSP::PerForm;
@@ -22,8 +22,8 @@
'file_upload($name;$value,$accept)',
'hidden($name;$value,$index)',
'textarea($name;$cols,$rows,$wrap,$default,$index)',
- 'single_select($name):itemtag=option',
- 'multi_select($name):itemtag=option',
+ 'single_select($name;$default,$index,*options):itemtag=option',
+ 'multi_select($name;@default,$index,*option):itemtag=option',
);
use strict;
@@ -426,8 +426,8 @@
};
}
-sub multi_select ($) {
- my ($name) = @_;
+sub multi_select ($;$$$) {
+ my ($name, $default, $index, $option) = @_;
my ($package) = caller;
no strict 'refs';
@@ -442,7 +442,7 @@
if ($params->{'__submitting'}) {
if (defined &{"${package}::validate_${name}"}) {
eval {
- "${package}::validate_${name}"->($ctxt, [$params->get($name)]);
+ "${package}::validate_${name}"->($ctxt, [$params->get($name.$index)],
+$index);
};
$error = $@;
$ctxt->{_Failed}++ if $error;
@@ -453,7 +453,11 @@
# load
my ($selected, @options);
if (defined &{"${package}::load_${name}"}) {
- ($selected, @options) = "${package}::load_${name}"->($ctxt,
[$params->get($name)]);
+ ($selected, @options) = "${package}::load_${name}"->($ctxt,
+[$params->get($name.$index)], $default, $index);
+ }
+ elsif (!$params->{'__submitting'}) {
+ $selected = [@{$default}];
+ @options = map { $$_{name}, $$_{value} } @{$option};
}
my %selected = map { $_ => 1 } @$selected;
@@ -469,6 +473,7 @@
multi_select => {
name => $name,
($error ? ( error => $error ) : ()),
+ index => $index,
options => [
map {
{
@@ -541,8 +546,8 @@
};
}
-sub single_select ($) {
- my ($name) = @_;
+sub single_select ($$$$) {
+ my ($name, $default, $index, $option) = @_;
my ($package) = caller;
no strict 'refs';
@@ -557,7 +562,7 @@
if ($params->{'__submitting'}) {
if (defined &{"${package}::validate_${name}"}) {
eval {
- "${package}::validate_${name}"->($ctxt, $params->{$name});
+ "${package}::validate_${name}"->($ctxt, $params->{$name.$index},
+$index);
};
$error = $@;
$ctxt->{_Failed}++ if $error;
@@ -568,7 +573,11 @@
# load
my ($selected, @options);
if (defined &{"${package}::load_${name}"}) {
- ($selected, @options) = "${package}::load_${name}"->($ctxt, $params->{$name});
+ ($selected, @options) = "${package}::load_${name}"->($ctxt,
+$params->{$name.$index}, $default, $index);
+ }
+ elsif (!$params->{'__submitting'}) {
+ $selected = $default;
+ @options = map { $$_{name}, $$_{value} } @{$option};
}
my (@keys, @vals);
@@ -582,6 +591,7 @@
single_select => {
name => $name,
($error ? ( error => $error ) : ()),
+ index => $index,
options => [
map {
{
@@ -814,7 +824,7 @@
triggered (as part of the submission procedure) and the browser will redirect to a
page
that handles the purchase of the associated item.
-NOTE: arrays not supported for multi-select, single-select or file-upload elements.
+NOTE: arrays not supported for file-upload elements.
=head1 TAG DOCUMENTATION
@@ -868,8 +878,9 @@
=back
-Note that <f:form> is the B<only> tag in PerForm that has content. All other tags are
empty,
-unless you define the attributes in child tags, as documented above.
+Note that <f:form> is the B<only> tag (besides <f:single-select/> and
+<f:multi-select/>)
+in PerForm that has content. All other tags are empty, unless you define the
+attributes
+in child tags, as documented above.
=head2 <f:submit/>
@@ -1248,7 +1259,8 @@
A drop-down select list of items.
-Both single-select and multi-select (below) are populated solely by callbacks.
+The single-select and multi-select (below) elements can be populated either by
+callbacks
+or through embedded elements.
B<Attributes:>
@@ -1258,6 +1270,37 @@
The name of the single select widget.
+=item default
+
+The default value that is to be selected.
+
+=item index
+
+Use this to identify the array index when using arrayed form elements.
+
+=back
+
+B<Elements:>
+
+=over 4
+
+=item <f:options>
+
+Child to a <f:single-select> element, this wraps around a listing of
+populated options
+
+=item <option>
+
+Child to <f:options>, this is an individual option
+
+=item <name>
+
+This is the name for a given option, to which it is a child
+
+=item <value>
+
+Similar to <name>, this indicates the value for an option
+
=back
B<Callbacks:>
@@ -1300,7 +1343,22 @@
The name of the multiple select widget.
+=item default
+
+The default value that is to be selected. This can be specified as
+a child element (e.g. <f:default>) in order to indicate multiple
+default values.
+
+=item index
+
+Use this to identify the array index when using arrayed form elements.
+
=back
+
+B<Elements:>
+
+The available child elements are identical to <f:single-select> so they will
+not be repeated here.
B<Callbacks:>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]