Question I have a rails app that I use to print labels. No matter what I have tried my select_tag will always default back to the first choice. I would like it to keep the choose I selected after the page reload/submit. Any help would be greatly appreciated.
Here is my form
= form_tag label_print_sessions_path, :method => 'get', :class => "form-horizontal" do
.row-fluid
.span6
=render "form_entry", :field_name => "print_job"
= text_field_tag :type, "manual", :style => 'display:none;'
.span6
=render "form_entry", :field_name => "description"
.row-fluid
.span6
=render "form_entry", :field_name => "total_qty"
.span6
=render "form_entry", :field_name => "qty_per_label"
These are the select tags that I want to keep the value selected after submitting the page.
.row-fluid
.span6
.control-group
= label_tag :printer, "Select a Printer: ", :class => 'control-label'
.controls
= select_tag :printer, options_for_select([["Printer 1", "10040"], ["Prototype", "10080"]], :selected => params[:printer], :input_html => {:value => ''})
.span6
.control-group
= label_tag :label_format, "Select a Format: ", :class => 'control-label'
.controls
= select_tag :label_format, options_for_select([["T-1. fmt", "11381"], ["G-2. fmt", "11380"], ["U-1. fmt", "11420"]], :selected => params[:label_format], :input_html => {:value => ''})
Aucun commentaire:
Enregistrer un commentaire