Page 1 of 1

Pre-selecting an existing item

Posted: 2020-01-12 14:37
by SSchimkat
Hi everyone

Been tweaking my AppGini app quite a loot .. but one thing is still bugging me: I cannot figure out, how to pre-select an item within a dropdown .. that's usually empty, when creating new records.

I need a hint on where to modify the code, for setting temporary defaults, for a specific dropdown - that normally has an empty default.

Anyone? :)

Re: Pre-selecting an existing item

Posted: 2020-01-12 20:19
by pbottcher
Hi,

you can try this:

add to the hooks/tablename.php -> tablename_dv function the following:

Code: Select all

if (!$selectedID) {
$html.=<<<EOC
<script>\$j(function() {if (AppGini.current_lookup.value=="") AppGini.current_lookup.value=1});</script>
EOC;
}
replace lookup with the fieldname that have for your lookup field and the 1 with the ID of your pre-selected item.

Re: Pre-selecting an existing item

Posted: 2020-01-14 08:22
by SSchimkat
Thanks .. worked as a charm. :-)