Skip to content

Instantly share code, notes, and snippets.

@scottshea
Created September 17, 2012 21:47
Show Gist options
  • Save scottshea/3739990 to your computer and use it in GitHub Desktop.
Save scottshea/3739990 to your computer and use it in GitHub Desktop.
Partial with select changing
<%= form_for :asset, :url => {:controller => "import", :action => "asset_check", :format => :js }, :options => { :remote => true }, :html => {:method => :post, :class => "well form-horizontal"} do |f| %>
<%= f.submit "Check File", :class => "btn" %> </br>
<%= f.label 'Configuration', "Field Mapping:", :class => "control-label" %>
<div class="controls">
<%= f.select('csv_configurations', options_from_collection_for_select(@csv_configurations, "id", "name"), {:include_blank => true}, {:id => "csv_configuration", :onchange => "load_mapping(this.value)"}) %>
</div>
<% @csv.headers.each do |head| %>
<%= f.label head, head.humanize, :class => "control-label", :id => "#{head}_id" %>
<div class="controls">
<% if @format %>
<%= f.select head, options_for_select(@asset_attrs,@mappings.find {|map| map.csv_field_name == head}.model_field_name) %>
<p>Meow</p>
<% else %>
<%= f.select head, options_for_select(["Choose Cetani field"] + @asset_attrs, "Choose Cetani field") %>
<% end %>
</div>
<% end %>
<%= f.hidden_field 'file', :value => @csv %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment