Buy Now
Sign in

editing autocomplete dropdown

E
emmexx 416
June 21 2018 #378495
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
E
emmexx 416
October 09 2018 #380676
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 5.1
October 09 2018 #380678
 Answer
Are you not able to add the default condition?
{var:read_data99.myTable.myField/(var:default_if_not_found)}
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
E
emmexx 416
October 09 2018 #380682
Are you not able to add the default condition?
{var:read_data99.myTable.myField/(var:default_if_not_found)}

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