Saghir A. Khatri
Saghir A. Khatri

Reputation: 3128

show option value selected in form select

my question is really of basic level, but seems like i am unable to figure out how i can do the following.

i have a form inside my view as follows

<%= form_for(@admin, :url => {:action => :update}) do |f| %>
    <%= f.label :Advance_Search_allow, "Allow advance search?" %>
    <%= f.select :Advance_Search_allow, options_for_select(["Yes", "No"]) %>

    <%= f.label :paid_Alert, "Number of alerts to send for Pro Users" %>
    <%= f.text_field :paid_Alert %>

    <%= f.label :basic_Alert, "Number of alerts to send for Basic Users" %>
    <%= f.text_field :basic_Alert %>

    <%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
<% end %>

the :paid_Alert and :basic_Alert are being populated as they are in db. but i am trying to populate select's option with that of the db and providing the other value as it is in shown in code. plz let me know how i can achieve this. Pardon me if my question sounds dumb and please point me the link if my question is duplicate. Thanks in Advnce

Upvotes: 0

Views: 178

Answers (1)

Satya Kalluri
Satya Kalluri

Reputation: 5214

Try options_for_select(["Yes", "No"], @admin.Advance_Search_allow

Upvotes: 1

Related Questions