Answer the question
In order to leave comments, you need to log in
How do I set the default value in an Active Admin form?
There is a form in active admin, it has a certain select of 4 items, I need to set one of these items by default, how can I do this?
def dropdown_select_collection_by(scope:)
DropdownOption.send(scope).pluck(:label, :id)
end
f.input(:work_status,
as: :select,
collection: dropdown_select_collection_by(scope: :work_status))
Answer the question
In order to leave comments, you need to log in
f.input(:work_status,
as: :select,
collection: dropdown_select_collection_by(scope: :work_status)),
selected: dropdown_select_collection_by(scope: :work_status)&.first || 'Default'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question