Quick question. When submitting a search, some of my fields save the user input in the text field or drop down menu after the search has been done, but for other fields, it reverts back to the default choice. How do I make them save the users choice.
Start date:
<%= select_tag "start_date_dd", options_for_select({
"Select a period" => "",
"3 days ago" => DateTime.now.to_date - 3.days, # = 259_200 sec.
"1 week ago" => DateTime.now.to_date - 1.week, # = 604_800 sec.
"1 month ago" => DateTime.now.to_date - 1.month, # = 2_592_000 sec.
"6 months ago" => DateTime.now.to_date - 6.months, # = 15_552_000 sec.
"1 year ago" => DateTime.now.to_date - 1.year, # = 31_557_600 sec.
}, :selected=>params[:start_date_dd] )%></br>
Status :
<%= select(@projects, :status, Project.all.map {|p| [p.status]}.uniq, :prompt => "-Any-", :selected => params[:status]) %></br>
Here my status dropdown box keeps the user input in the text box, but my start date drop down menu does not. Any way around this. Thanks
:selected => params[:status] is why your status drop box keeps the value
you would need to add :selected=>params[:start_date_dd] added to the tag