Item2096: Select form fields drop down box is not working for entries containing commas

pencil
Priority: Normal
Current State: No Action Required
Released In: n/a
Target Release: patch
Applies To: Engine
Component:
Branches:
Reported By: SimonKlempert
Waiting For:
Last Change By: CrawfordCurrie
Form fields of type select are not keeping their stored selection in edit mode if using values with commas. If selecting a value with comma, it is stored correctly in the files, but in edit mode the corresponding option does not get the select attribute.

Example form defintion:
| *Name* | *Type* | *Size* | *Values* | *Tooltip message* | *Attributes* | 
...
| [[AllCpuIDLoginNamePreProd][--HOST_PREPROD]] | select | 1 | | Select the CPU_ID & LOGIN_NAME for pre-production| |
...

Example value defintion in AllCpuIDLoginNamePreProd:
| *Name* | *Type* | *Tooltip message* |
| -, -, - | option | |
| XXX, yyyy, zzz | option | |
| ZZZ, vvvv, ddd | option | |

Steps to reproduce:
  • Create form definition
  • Create topic using this form
  • Select some value with comma
  • Save (value is correct in edit)
  • Edit (--> previously stored value is not shown is not selected in drop down box)

(Before update from old TWiki to Foswiki this was working)


REF: http://irclogs.foswiki.org/bin/irclogger_log/foswiki?date=2009-12-04,Fri&sel=217#l213

From IRC this fix is proposed (author classifies this as hack)

--- Select.pm.dist      2009-06-21 23:22:25.000000000 +0200
+++ Select.pm   2009-09-18 12:32:48.666102000 +0200
 -93,7 +93,13 @@

     my $choices = '';

-    my %isSelected = map { $_ => 1 } split( /\s*,\s*/, $value );
+
+    my %isSelected;
+    if ( $this->isMultiValued() ) {
+      %isSelected = map { $_ => 1 } split( /\s*,\s*/, $value );
+    } else {
+      $isSelected{$value} = 1;
+    }
     foreach my $option ( @{ $this->getOptions() } ) {
         my %params = ( class => 'foswikiOption', );
         $params{selected} = 'selected' if $isSelected{$option};

I include it now because IRC is a thing that gets lost quickly

-- KennethLavrsen - 04 Dec 2009

Works fine in 1.1, so I'm closing it.

-- CrawfordCurrie - 25 Aug 2010

Checked with version 1.1.2 in our installation and it is not working. Reopened.

-- SimonKlempert - 07 Jan 2011

I beg to differ; it works perfectly. Suggest you review your data files; especially AllCpuIDLoginNamePreProd where I suspect your table of fields may not be formatted correctly. If you still feel it is broken, please re-open this with a full example.

-- CrawfordCurrie - 13 Oct 2011

ItemTemplate edit

Summary Select form fields drop down box is not working for entries containing commas
ReportedBy SimonKlempert
Codebase 1.1.2, 1.1.1, 1.1.0, 1.1.0 beta1, 1.0.10, 1.0.9, 1.0.8, 1.0.7, 1.0.6, trunk
SVN Range Foswiki-1.0.6, Sun, 21 Jun 2009, build 4272
AppliesTo Engine
Component
Priority Normal
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease patch
ReleasedIn n/a
Topic revision: r7 - 13 Oct 2011, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy