Ticket #376 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

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

basic-controls.diff (831 bytes) - added by sdm 3 years ago.
basic-controls.js: patch to solve default selection of multivalue selection-control

Change History

Changed 3 years ago by sdm

basic-controls.js: patch to solve default selection of multivalue selection-control

comment:1 Changed 3 years ago by sdm

  • Description modified (diff)

comment:2 Changed 3 years ago by mpo

  • Status changed from new to closed
  • Resolution set to fixed

(In [1726]) fixes #376
selection controls in multivalue mode are capable of having nothing selected.

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}"
	}
    }
}

comment:4 Changed 3 years ago by mpo

  • Status changed from reopened to closed
  • Resolution set to fixed

(In [1732]) fix #376 in case of no-string the trim-to-options will receive val==null (not undefined)

Note: See TracTickets for help on using tickets.