Author: richter
Date: Mon Jan 26 07:37:21 2015
New Revision: 1654732

URL: http://svn.apache.org/r1654732
Log:
Add autoselect to select control

Modified:
    perl/embperl/trunk/Embperl/Form/Control/select.pm

Modified: perl/embperl/trunk/Embperl/Form/Control/select.pm
URL: 
http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/select.pm?rev=1654732&r1=1654731&r2=1654732&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/select.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/select.pm Mon Jan 26 07:37:21 2015
@@ -41,6 +41,8 @@ sub show_control
 push @{$req -> {timing}}, ([Time::HiRes::gettimeofday], 'start show_control ' 
. $self->{name} . ' ' . __FILE__ . '#' . __LINE__) if ($req -> {timing});
     
     my $name     = $self -> {name} ;
+    my $fdat     = $req -> {docdata} || \%Embperl::fdat ;
+    my $value    = $fdat -> {$name} ;
     $filter      ||= $self -> {filter} ;
     my $nsprefix = $self -> form -> {jsnamespace} ;
     my $val ;
@@ -56,11 +58,15 @@ push @{$req -> {timing}}, ([Time::HiRes:
     $out .= ' _ef_attach="ef_select" ' if ($self -> {trigger}) ;
     push @{$req -> {timing}}, ([Time::HiRes::gettimeofday], 'start 
show_control4 ' . $self->{name} . ' value: ' . scalar(@$values) . ' : ' . 
__FILE__ . '#' . __LINE__) if ($req -> {timing});
     my $i = 0 ; 
+    my $escval ;
+    my $escopt ;
+    my $selected ;
     foreach $val (@$values)
         {
-        my $escval = escape_html ($val) ;
-        my $escopt = escape_html ($options ->[$i])  ;
-        push @opt, qq{<option value="$escval">} . ($escopt) . q{</option>} if 
(!defined ($filter) || ($val =~ /$filter/i)) ;
+        $escval = escape_html ($val) ;
+        $escopt = escape_html ($options ->[$i])  ;
+        $selected = $val eq $value?'selected':'' ;
+        push @opt, qq{<option value="$escval" $selected>} . ($escopt) . 
q{</option>} if (!defined ($filter) || ($val =~ /$filter/i)) ;
         $i++ ;
         }
     $out .= ">\n" . join ("\n", @opt) . "\n" . '</select>' . "\n" ;



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscr...@perl.apache.org
For additional commands, e-mail: embperl-cvs-h...@perl.apache.org

Reply via email to