From ce4040f7276a68797ab901cabdea4382f8df2ea9 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 29 Oct 2002 04:20:08 +0000 Subject: [PATCH] Added the whatNext method. --- lib/WebGUI/Form.pm | 41 ++++++++++++++++++++++++ lib/WebGUI/HTMLForm.pm | 72 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 112 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index 3b74d4673..959673a3e 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -1226,6 +1226,47 @@ sub url { #------------------------------------------------------------------- +=head2 whatNext ( hashRef ] ) + + Returns a "What next?" select list for use with chained action forms + in WebGUI. + +=item options + + A hash reference of the possible actions that could happen next. + +=item value + + The selected element in this list. + +=item name + + The name field for this form element. Defaults to "proceed". + +=item extras + + If you want to add anything special to this form element like + javascript actions, or stylesheet information, you'd add it in + here as follows: + + 'onChange="this.form.submit()"' + +=cut + +sub whatNext { + my ($name); + $name = $_[0]->{name} || "proceed"; + return selectList({ + options=>$_[0]->{options}, + name=>$name, + value=>[$_[0]->{value}], + extras=>$_[0]->{extras} + }); + +} + +#------------------------------------------------------------------- + =head2 yesNo ( hashRef ) Returns a yes/no radio field. diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index bdf0d4926..54b6c95d1 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -690,7 +690,7 @@ sub group { $output = WebGUI::Form::hiddenList({ name=>$name, options=>$hashRef, - groupId=>$value + value=>$value }); } $self->{_data} .= $output; @@ -1779,6 +1779,76 @@ sub url { #------------------------------------------------------------------- +=head2 whatNext ( hashRef ] ) + + Adds a "What next?" select list to this form for use with chained + action forms in WebGUI. + +=item options + + A hash reference of the possible actions that could happen next. + +=item value + + The selected element in this list. + +=item name + + The name field for this form element. Defaults to "proceed". + +=item label + + The left column label for this form row. + +=item subtext + + Extra text to describe this form element or to provide special + instructions. + +=item uiLevel + + The UI level for this field. See the WebGUI developer's site for + details. Defaults to "1". + +=cut + +=item extras + + If you want to add anything special to this form element like + javascript actions, or stylesheet information, you'd add it in + here as follows: + + 'onChange="this.form.submit()"' + +=cut + +sub whatNext { + my ($output); + my ($self, @p) = @_; + my ($options, $value, $name, $label, $subtext, $uiLevel, $extras) = + rearrange([options, value, name, label, subtext, uiLevel, extras], @p); + $uiLevel |= 1; + $label |= WebGUI::International::get(744); + if (_uiLevelChecksOut($uiLevel)) { + $output = WebGUI::Form::whatNext({ + name=>$name, + options=>$options, + value=>$value, + extras=>$extras + }); + $output .= _subtext($subtext); + $output = $self->_tableFormRow($label,$output); + } else { + $output = WebGUI::Form::hidden({ + name=>$name, + value=>$value + }); + } + $self->{_data} .= $output; +} + +#------------------------------------------------------------------- + =head2 yesNo ( name [ label, value, extras, subtext, uiLevel ] ) Adds a yes/no radio menu to this form.