You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't set value of select type field in form for edit #1299
I've combed over the docs, tried a lot of things, and I cannot see any way to set the value of a search field using select and option_source in an edit form.
It works fine from scratch on my add form to make a new record, but in the edit form on an existing record this field always comes up blank. I've tried setting value, selected, and label_value at the row level in the form SQL, I've tried using some json like this (per a forum post):
select'json'as component;
SELECTtracks.idAS value,
tracks.titleAS label,
tracks.id= CAST($track_key ASINT) AS selected
FROM tracks
WHERElower(title) LIKE'%'||lower($search) ||'%';
But that fails with an error message saying that the json array only supports label and value keys.
So how exactly does one successfully use a select type with a pre-set value for edit?
There is no clean way to do what you want with options source, but here is a workaround:
select'shell'as component, 'options_source edit workaround'as title;
select'text'as component, 'Edit record with remote-search select'as title;
select'form'as component, 'Submit'as validate, 'post'as method, 'index.sql'as action;
select'select'as type,
'track_id'as name,
'Track'as label,
id as value,
true as searchable,
'tracks.sql'as options_source,
json_group_array(json_object('value', id, 'label', title)) as options,
'The current edit value is preloaded, and more options load as you search.'as description
from tracks
where id =2;
I'll see if we can have a proper fix in the next version
Activity
lovasoa commentedon Jun 8, 2026
Hi !
Thanks for the detailed report.
There is no clean way to do what you want with options source, but here is a workaround:
I'll see if we can have a proper fix in the next version
lovasoa commentedon Jun 8, 2026
I ended up updating just the documentation. I think combining options and options_source is actually a good solution.