Ticket #376 (closed defect: fixed)
Multivalue selection-control problems
| Reported by: | sdm | Owned by: | mpo |
|---|---|---|---|
| Priority: | major | Milestone: | 0.4 |
| Component: | modules/kauri-forms | Version: | |
| Keywords: | Cc: | kauri-discuss@… |
Description (last modified by sdm) (diff)
I discovered 2 problems when using a multivalue selection-control:
1) Error on empty selection:
- If you select a value and then deselect it again so that nothing is
selected anymore, I get the following error: "Formatting error
TypeError?: val is null"
2) Inconsistent JSON data when only one value is selected:
- If the control is not nullable, the first option is selected by
default. If you post the form, the value is sent like this: "2"
- If you select another option and then reselect the first option,
then the value that is sent after form submission is [ "2" ] (it should
probably always send an array with one value).
I think it would also be better if no value was selected by default.
For a regular "one value" selection-control, you always have to select
a value (even if that value is nothing more than "Please select an
option"), so it's logical in this case that the first value is
automatically selected, but for a multivalue selection-control, it's
also possible to select nothing, so I think that it's not necessary to
select the first option by default.
+ if nothing was selected by default, problem 2) would probably also
be solved.
I've added a patch to solve the default selection problem.
Attachments
Change History
Changed 3 years ago by sdm
- Attachment basic-controls.diff added
comment:3 Changed 3 years ago by mpo
- Status changed from closed to reopened
- Resolution fixed deleted
snatched from the mailinglist: Apparently, the error occurs if base=integer. If base=string,
everything seems to work correctly. I edited the selection-control
sample page to demonstrate the error on empty selection:
"carmakesMulti": {
"base": "integer",
"label": "Select some carmakes",
"multivalue": true,
"control": {
"base": "selection-control",
"size": 8,
"options": {
"uri": "${publicUri('service:/data/carmake')}",
"valueTemplate": "{id}",
"labelTemplate": "{name}"
}
}
}
basic-controls.js: patch to solve default selection of multivalue selection-control