1

I have this form and tried many aproches to no avail to repopulate form fields for a rails form_for after submit. Whats the correct way to do it? Maybe just overlook in the docs but no good reference on how to to this :(

The only non working solution is to use the params tag and set the collections default value to that, but if form not submitted this fails too. params[:age_from]

= form_for :people, :url => request.fullpath, :method => :get, :html => { :class => 'form-search' } do |f|

  #container_search
    .clear
      = select_tag(:age_from, options_for_select(18..60)
      = select_tag(:age_to, options_for_select(18..60)
      = select_tag(:gender, options_for_select(gender)
    .clear
    .center
      = f.submit "Search ยป", :class => "span-4"
Rubytastic
  • 15,001
  • 18
  • 87
  • 175

1 Answers1

0

It looks like you are missing closing ) on your select_tag lines, you can add selected value by adding another param to your options_for_select:

select_tag(:age_from, options_for_select(18..60, params[:age_from]))
iouri
  • 2,919
  • 1
  • 14
  • 11