[MGNLFORM-123] Selection Checkbox, select (single/multiple) and radio buttons don't allow multiple selection Created: 13/Mar/12  Updated: 09/Oct/12  Resolved: 24/Jul/12

Status: Closed
Project: Magnolia Form Module
Component/s: None
Affects Version/s: 1.4.1
Fix Version/s: 1.4.3

Type: Bug Priority: Major
Reporter: Eric Hechinger Assignee: Milan Divilek
Resolution: Fixed Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

4.5.1 EE


Attachments: File formSelection-DECODED.ftl     File formSelection.ftl    
Issue Links:
causality
duplicate
is duplicated by MGNLFORM-132 Selector/radio/check field does not work Closed
is duplicated by MGNLFORM-127 Display only first value of Selection... Closed
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Not able to define multiple select with the recomended syntax:
bar:bar
baz:baz
bat:bat

Just display the first entry.



 Comments   
Comment by Antti Hietala [ 20/Apr/12 ]

The issue happens when the label-values pairs entered by the user are split into a list. The component script splits them at the line feed + carriage return (CR+LF, \r\n) character sequence:

[#list content.labels?split("\r\n") as label]

This doesn't work. If you separate the label-value pairs with pretty much any other character (try "MOO") and split them at that char in the script, it works.

Comment by Marvin Kerkhoff [ 21/May/12 ]

Why not use | instead of \r\n ? Please use another splitter as \r\n.

Comment by Christian Ringele [ 21/May/12 ]

Even with no splitter it doesn't work.
Try this:
One
Two

Here:
http://demo.magnolia-cms.com/demo-features/special-templates/multi-step-form/enter-topic.html?mgnlCK=1337606308438

Comment by Marvin Kerkhoff [ 22/May/12 ]

Here is the right template for that (formSelection.ftl). I also add the possibility to add optgroups in a select element. Like in this Case:

Main Countries

{Schweiz:Schweiz|Deutschland:Deutschland|Österreich:Österreich}

Other Countries

{Afghanistan:Afghanistan|Ägypten:Ägypten|Albanien:Albanien|}
Comment by Samuel Schmitt [ 12/Jul/12 ]

A better solution is to decode the content and keep the original script.

Just do the list of the labels as following

[#list cmsfn.decode(content).labels?split("\r\n") as label]
Comment by Jan Haderka [ 19/Jul/12 ]

Not convinced by the current fix.
According to Java documentation:

Line terminators

A line terminator is a one- or two-character sequence that marks the end of a line of the input character sequence. The following are recognized as line terminators:

A newline (line feed) character ('\n'),
A carriage-return character followed immediately by a newline character ("\r\n"),
A standalone carriage-return character ('\r'),
A next-line character ('\u0085'),
A line-separator character ('\u2028'), or
A paragraph-separator character ('\u2029).

so whatever solution we choose should be able to split by all of those terminators not just by one out of 6 possible.

FM supports flags for split so you can use

.split("regex", rm)

(r for regex and m for multiline matching) and construct regex that would match all of those separators.

Generated at Mon Feb 12 05:37:05 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.