Forums

editing autocomplete dropdown

emmexx 21 Jun, 2018
I'm trying to find out a way to edit a field (that is reload a record in a form and populate every field) that is set as an autocompleter dropdown.

Is that possible? Should I give up on using the autocomplete feature?

Thank you
maxx
emmexx 09 Oct, 2018
I thought I found a reliable solution to my question but I found out I was wrong.

I used the options and Selected values in order to load the correct option when the Selected values is read when reloading a record. The problem is that that works fine when there's a record but if there's a validation error and the record field is empty CF uses the value from the record and not the session value.
Some more detail:

I setup a form with a Dropdown control set up as an Autocomplete field (AutoComplete event).
I set the Options field with something like {var:myfield_txt} where myfield_txt is a string formatted as an array of key/value pairs. The variable has 0 or one row, 0 if I'm creating a new record, one row if I'm reloading one record in the form.

The Selected values field is set to {var:read_data99.myTable.myfield}. When I reload a record in the form the dropdown has only one row with a value that is equal to {var:read_data99.myTable.myfield}.

That works fine if myfield is not empty and there's not a validation problem. In the latter case when the form is reloaded, the dropdown Selected values is set to nothing, not to the session value of the field.
I should probably set up a test form.

The problem is that the Autocomplete dropdown is more complex than a simple dropdown and it wasn't created having in mind the possibility of reloading a form.

bye
maxx
healyhatman 09 Oct, 2018
Answer
Are you not able to add the default condition?
{var:read_data99.myTable.myField/(var:default_if_not_found)}
emmexx 09 Oct, 2018
[blockquote]Are you not able to add the default condition?
{var:read_data99.myTable.myField/(var:default_if_not_found)}[/blockquote][br]I solved in a similar way. The only difference is that the default value is a session variable, the value for the field input by the user before submitting:
{var:read_data99.myTable.myField/(session:mysession.myfield)}
(I used a switch and not that syntax, I didn't test if the session shortcode works as default value of a var.

Anyway the meaning of my post was because a dropdown with Autocomplete works differently from other controls upon reload. I found a way to make it work after lots of trial and error.

Thank you
maxx
This topic is locked and no more replies can be posted.