From a4afb3e0641094958ec3b9fbc395d8dc4e3f9d6e Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 13 Aug 2002 03:09:31 +0000 Subject: [PATCH] Added some missing form elements. --- lib/WebGUI/HTMLForm.pm | 189 +++++++++++++++++++++++++++++++++++++++++ lib/WebGUI/Wobject.pm | 2 +- 2 files changed, 190 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index e0bab6dc4..affbc0938 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -141,6 +141,74 @@ sub checkbox { #------------------------------------------------------------------- +=head2 checkList ( name, options [ label, value, vertical, extras, subtext ] ) + + Adds a checkbox list row to this form. + +=item name + + The name field for this form element. + +=item options + The list of options for this list. Should be passed as a + hash reference. + +=item label + + The left column label for this form row. + +=item value + + The default value(s) for this form element. This should be passed + as an array reference. + +=item vertical + + If set to "1" the radio button elements will be laid out + horizontally. Defaults to "0". + +=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()"' + +=item subtext + + Extra text to describe this form element or to provide special + instructions. + +=cut + +sub checkList { + my ($label, $subtext, $class, $output, $vertical, $value, $key, $item, $name, $options, $extras); + $class = shift; + $name = shift; + $options = shift; + $label = shift; + $value = shift; + $vertical = shift; + $extras = shift; + $subtext = shift; + foreach $key (keys %{$options}) { + $output .= ''.${$options}{$key}.'    '; + $output .= '
' if ($vertical); + } + $output .= _subtext($subtext); + $output = _tableFormRow($label,$output) unless ($class->{_noTable}); + $class->{_data} .= $output; +} + +#------------------------------------------------------------------- + =head2 combo ( name, options [ label, value, size, multiple, extras, subtext ] ) Adds a combination select list / text box row to this form. If the @@ -956,6 +1024,127 @@ sub printRowsOnly { #------------------------------------------------------------------- +=head2 radio ( name [ label, checked, subtext, value, extras ] ) + + Adds a radio button row to this form. + +=item name + + The name field for this form element. + +=item label + + The left column label for this form row. + +=item checked + + If you'd like this radio button to be defaultly checked, set this to "1". + +=item subtext + + Extra text to describe this form element or to provide special + instructions. + +=item value + + The default value for this form element. Defaults to "1". + +=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 radio { + my ($subtext, $class, $output, $name, $label, $extras, $checked, $value); + $class = shift; + $name = shift; + $label = shift; + $checked = shift; + $checked = ' checked="1"' if ($checked); + $subtext = shift; + $value = shift || 1; + $extras = shift; + $output = ''; + $output .= _subtext($subtext); + $output = _tableFormRow($label,$output) unless ($class->{_noTable}); + $class->{_data} .= $output; +} + +#------------------------------------------------------------------- + +=head2 radioList ( name, options [ label, value, vertical, extras, subtext ] ) + + Adds a radio button list row to this form. + +=item name + + The name field for this form element. + +=item options + The list of options for this list. Should be passed as a + hash reference. + +=item label + + The left column label for this form row. + +=item value + + The default value(s) for this form element. This should be passed + as an array reference. + +=item vertical + + If set to "1" the radio button elements will be laid out + horizontally. Defaults to "0". + +=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()"' + +=item subtext + + Extra text to describe this form element or to provide special + instructions. + +=cut + +sub radioList { + my ($label, $subtext, $class, $output, $vertical, $value, $key, $item, $name, $options, $extras); + $class = shift; + $name = shift; + $options = shift; + $label = shift; + $value = shift; + $vertical = shift; + $extras = shift; + $subtext = shift; + foreach $key (keys %{$options}) { + $output .= ''.${$options}{$key}.'    '; + $output .= '
' if ($vertical); + } + $output .= _subtext($subtext); + $output = _tableFormRow($label,$output) unless ($class->{_noTable}); + $class->{_data} .= $output; +} + +#------------------------------------------------------------------- + =head2 raw ( value ) Adds raw data to the form. This is primarily useful with the diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm index c8c055f7d..1788d69a3 100644 --- a/lib/WebGUI/Wobject.pm +++ b/lib/WebGUI/Wobject.pm @@ -644,7 +644,6 @@ sub www_delete { $output .= '    '; $output .= WebGUI::International::get(45); $output .= ''; - WebGUI::ErrorHandler::audit("moved Wobject ".$_[0]->{_property}{wobjectId}." to the trash."); return $output; } else { return WebGUI::Privilege::insufficient(); @@ -662,6 +661,7 @@ sub www_delete { sub www_deleteConfirm { if (WebGUI::Privilege::canEditPage()) { $_[0]->set({pageId=>3, templatePosition=>0}); + WebGUI::ErrorHandler::audit("moved Wobject ".$_[0]->{_property}{wobjectId}." to the trash."); _reorderWobjects($_[0]->get("pageId")); return ""; } else {