Why does the Auto Complete have an undefined value when submitting the form with typed data
I have noticed that auto complete elements do not populate the 'value' field if you don't select from the list of suggested options. note that the 'label' field is always populated with the user input.
For example if I type "tu14":
$searchForm.state.ac_roadId.value (This is undefined)
$searchForm.state.ac_roadId.label (This works and is set to tu14)
If I select from the list of suggested values from the auto complete then everything works as expected with $searchForm.state.ac_roadId.value being set to tu14.
Any idea what is going on here?
-
Hi Matthew,
It has to do with the way that suggestions are populated from the autocomplete's subworkflow. You'll typically have either a Get Form Element Items From Features or Get Form Element Items From Collection activity in that subworkflow (followed by Set Form Element Items). If you take a look at that activity, there is both a "label" input and a "value" input. In a lot of cases, you'd use the same attribute for both the label and value. But in some cases you'd want two different properties there.
For example, when using Get Form Element Items From Features, maybe you want the user to type an address, but then have the form pass on the parcel number instead of the address (so that you can query another layer using that value later). This kind of setup is probably more popular for dropdowns and listboxes than autocompletes, but both use the same "form item elements" structure and activities.
In this example, we'd write the rest of our workflow to expect that value output to contain a parcel number. If a user types an address that doesn't appear in the autocomplete's suggestions list, then we wouldn't want/expect it to have any value. We wouldn't have a matching parcel number for the address they typed.
I think for most uses of autocomplete, it's probably safest to use just the label property and ignore the value property. Otherwise you you would want your users to be aware of the difference, or you would want to build the workflow to check in both properties.
0 -
Thanks for the info Amanda,
I'd agree that I prefer the flexibility to set different value/label pairs on auto-complete. I also agree that this setup is more geared towards drop-downs/lists/radio-boxes.
Thoughts on the logic here when the value and label are different --> say the user is allowed to type whatever they want but don't choose from the suggestions ~ The value field will be undefined and there are likely to be errors in processing the workflow.
In that^ case you'd want to do validation over user education. Users would be educated by the form validation anyway by getting the error message about choosing from the suggestions. <-- This is a good solution in my opinion.
As you've mentioned, we found the label value to be best to use. Works like a charm.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
2 Kommentare