Ticket #372 (closed enhancement: fixed)
Initial empty value of case-control overrides case members' initial value
| Reported by: | idbr | Owned by: | karel |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.4 |
| Component: | modules/kauri-forms | Version: | |
| Keywords: | Cc: | kauri-discuss@… |
Description
If a case has an initial value of "case" (for specifying the initially selected case), but no "value" element (for initializing element in aforementioned case), the form for this case is initialized with empty values, disregarding possible initial values in the controls of that form.
An example to clarify things, change the case sample as follows:
- Remove the "value" element in the initial value of the case control
"initial":{"value": {"case":"t"}} - Add a control part with an initial value to the case t
"t" : { "base": "string", "label": "Text", "control": { "base": "input-control", "initial": { "value": "initialized by control" } } },
As you'll see, the input box is be empty. But when you change the initial selected case to n:
"initial":{"value": {"case":"n"}}
and select the case Text, it will contain the value "initialized by control".
Change History
comment:2 Changed 3 years ago by karel
@ibdr: I can acknowledge the fact that the initial value is not set,
but setting the initial selected case to "n" does not seem to make any difference afaict. (Possibly due to another change) Can you confirm this?
comment:3 Changed 3 years ago by karel
- Owner changed from mpo to karel
- Status changed from new to accepted
comment:4 Changed 3 years ago by karel
Never mind my remark, I messed up copy-pasting a bit. I can reproduce the problem as described.
comment:5 Changed 3 years ago by karel
analysis: see AbstractContainerControl?.reset:
If there is an initial value on the (parent) control, the child controls are not reset,
but reset is called on the super class (Control.reset).
In our case there is an initial value ({case:'t'}), but when setting it the child control (case-t) gets initial.value.value, which is undefined.