Fix handling of multi-form and multiple select form elements by emitting

a hidden form variable to make sure the form element was in the generated form.
Changes in User and ProfileField to support this.
This commit is contained in:
Colin Kuskie 2009-01-26 21:03:23 +00:00
parent 83d1203de9
commit 41da738e0e
9 changed files with 134 additions and 17 deletions

View file

@ -98,6 +98,19 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 isInRequest ( )
=cut
sub isInRequest {
my $self = shift;
my $form = $self->session->form;
return $form->hasParam($self->privateName('isIn'));
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a select list form control.
@ -105,9 +118,10 @@ Renders a select list form control.
=cut
sub toHtml {
my $self = shift;
my $self = shift;
my $session = $self->session;
my $multiple = $self->get("multiple") ? ' multiple="multiple"' : '';
my $output = '<select name="'.($self->get("name")||'').'" size="'.($self->get("size")||'').'" id="'.($self->get('id')||'').'" '.($self->get("extras")||'').$multiple.'>';
my $output = '<select name="'.($self->get("name")||'').'" size="'.($self->get("size")||'').'" id="'.($self->get('id')||'').'" '.($self->get("extras")||'').$multiple.'>';
my $options = $self->getOptions;
my @values = $self->getOriginalValue();
foreach my $key (keys %{$options}) {
@ -120,6 +134,7 @@ sub toHtml {
$output .= '>'.$options->{$key}.'</option>';
}
$output .= '</select>'."\n";
$output .= WebGUI::Form::Hidden($session, { name => $self->privateName('isIn'), value => 1, });
return $output;
}