Stream: questionnaire
Topic: autofill for lists of length 1
Paul Lynch (Mar 21 2022 at 23:23):
LHC-Forms (at least in version 30) currently autofills fields which have a list with just one item, with that item, because there is only one option. By that I mean that when the form first renders, the value is already filled in without the user having to enter it. Usually such cases arise because the field's list is set by answerExpression. I'm thinking that should probably not be a default behavior, and we should turn that off, especially for open-choice lists, but probably also for choice lists. However, there are circumstances where that would be convenient, in the same way that form prepopulation is convenient. Should be a way to indicate that that kind of autofill is desired?
I suppose initialExpression could be used to set the value if there just one item in the list, but it is not very convenient if that is something that would be often wanted.
Diane (Mar 21 2022 at 23:51):
When working with LHC-Forms, to me, it is tricky to know if an expression is returning a string, a list with one item or a whole long list. type() doesn't seem to output enough useful information. So, if I want LHC-Forms to "know" that I want the 1st or only item in the list, I have been indicating this with a syntax like item.answer[0].value.
Lloyd McKenzie (Mar 22 2022 at 01:44):
To indicate a desire to auto-fill, the system can (and should) specify an initial.value[x] or an initialValueExpression. In the absence of those, the initial value should be "not answered".
Last updated: Apr 12 2022 at 19:14 UTC