Skip to content

Commit

Permalink
Item8388: Fix pre-selecting multiple items in multi-select form elements
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/FormPlugin@7414 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed May 15, 2010
1 parent 43f3c46 commit 50ec8a2
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions lib/Foswiki/Plugins/FormPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (c) 2007, 2008, 2009 Arthur Clemens, Sven Dowideit, Eugen Mayer
# Copyright (c) 2007-2010 Arthur Clemens, Sven Dowideit, Eugen Mayer
# All Rights Reserved. Foswiki Contributors
# are listed in the AUTHORS file in the root of this distribution.
# NOTE: Please extend that file, not this notice.
Expand Down Expand Up @@ -59,7 +59,7 @@ my $SEP;
my $STATUS_NO_ERROR = 'noerror';
my $STATUS_ERROR = 'error';
my $STATUS_UNCHECKED = 'unchecked';
my $DEFAULT_METHOD = 'POST';
my $DEFAULT_METHOD = 'post';
my $FORM_SUBMIT_TAG = 'FP_submit';
my $ACTION_URL_TAG = 'FP_actionurl';
my $VALIDATE_TAG = 'FP_validate';
Expand Down Expand Up @@ -202,8 +202,6 @@ sub beforeCommonTagsHandler {

return if !defined $submittedFormName;

_debug("beforeCommonTagsHandler; submittedFormName=$submittedFormName");

if ($submittedFormName) {

# process only once
Expand Down Expand Up @@ -262,6 +260,8 @@ sub _startForm {
return '' if $expandedForms{$name};

#allow us to replace \n with something else.
# quite a hack here, isn't it
# TODO: fix
$SEP = $params->{'sep'} if ( defined( $params->{'sep'} ) );
my $showErrors = lc( $params->{'showerrors'} || 'above' );

Expand Down Expand Up @@ -1110,11 +1110,11 @@ sub _getFormElementHtml {
my $selectedoptions = $params->{'default'} || undef;
my $isMultiple = $MULTIPLE_TYPES{$type};
if ($isMultiple) {
my @values = param($name);
my @values = $params->{'value'};
$selectedoptions ||= join( ",", @values );
}
else {
$selectedoptions ||= param($name);
$selectedoptions ||= $params->{'value'};
}

my $disabled = $params->{'disabled'} ? 'disabled' : undef;
Expand Down Expand Up @@ -1832,23 +1832,12 @@ sub _wrapHtmlMandatoryContainer {
return CGI::span( { class => $MANDATORY_CSS_CLASS }, $text );
}

=pod
Shorthand function call.
=cut

sub _debug {
my ($text) = @_;
Foswiki::Func::writeDebug("$pluginName:$text") if $text && $debug;
}

sub _trimSpaces {

#my $text = $_[0]
return if !$_[0];
$_[0] =~ s/^[[:space:]]+//s; # trim at start
$_[0] =~ s/[[:space:]]+$//s; # trim at end
$_[0] =~ s/^[[:space:]]+//s; # trim at start
$_[0] =~ s/[[:space:]]+$//s; # trim at end
}

=pod
Expand Down Expand Up @@ -1899,4 +1888,18 @@ sub _allowRedirects {
return 1;
}

=pod
Shorthand function call.
=cut

sub _debug {
my ($text) = @_;

#print STDERR "_debug; debug=$debug; text=$text\n"; # only for unit tests

Foswiki::Func::writeDebug("$pluginName:$text") if $text && $debug;
}

1;

0 comments on commit 50ec8a2

Please sign in to comment.