Reputation: 5895
As an active admin column i need a dropdown list. I've done
column "Action" do
select :design, :collection => options_for_select(['a','b','c'])
end
it only shows b and c,
but option a is not showing in the dropdown list. Why? How can I solve that?
If I give ['ad', 'as', 'dsa', 'asfs']
the last three values are showing. The first one 'ad'
is vanished.
Upvotes: 3
Views: 3016
Reputation: 802
I am using rails 6 and active_admin 2.7.0
I don't know why would one complicate things if this can be done so simply as:
form title: 'Action' do |f|
input :design, collection: ['a', 'b', 'c']
end
I hope there is nothing wrong with it because I am doing this and works fine for me! Hope this helps somebody :)
Upvotes: 1
Reputation: 4831
I came across almost the same problem, so using your example
column "Action" do
select :design, :collection => options_for_select(['a','b','c'])
end
Gave the html
<select collection="<option value="a"="">a
<option value="b">b</option>
<option value="c">c</option>
design
</select>
Which like your question pointed out, is only showing options b
and c
I don't know why it's always putting the first option tag inside the select tag but if anyone has the answer, please share!
But, the way we worked around that was by setting each <option>
tag ourselves
select :design do
%w(a b c).each do |opt|
option opt, :value => opt
end
end
Which gave us the html
<select> design
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
Which shows the options a
, b
, and c
I'm not sure if this is the answer you are looking for but I hope this helps.
Upvotes: 3
Reputation: 5075
is this for a form?
if that's the case it should go something like this
f.input :design, :as => :select, :collection => ["a","b","c"]
where f would be the parameter for the form
i'm guessing you are having css issues because is not define for a column case
Upvotes: 2