I know some will think that i should use form_tag with :remote=>true, but i don't know how to render an entire html output....
My problem is the following:
I have this form that sends a collection through 3 comboxes
<%= form_remote_tag :url => report_client_reports_path, :update => :graphic do%>
<%#= form_tag reporte_client_reports_path%>
<p><%= label_tag :supermercados %>
<%=select_tag "supermercados[]", options_from_collection_for_select(@supermercados, "id", "name"),{:multiple=>true, :id => "supermarkets"}%>
</p>
<p><%= label_tag :开发者_StackOverflowcortes %>
<%=select_tag "cortes[]", options_from_collection_for_select(@cortes, "corte_real","cuts"),{:multiple=>true, :id => "cortes"}%>
</p>
<p><%= label_tag :productos %>
<%= select_tag "productos[]", options_from_collection_for_select(@productos, "id", "name"),{:multiple=>true, :id => "products"}%>
</p>
<p><%= submit_tag 'Send' %></p>
<%end%>
If i uncommented this line: <%#= form_tag reporte_client_reports_path%> It work good and present me the graph, but not the way i expect to work.
I have detected that using form_remote_tag, it sends all vars with their values, bu i dont know why my controller only see one value of each variable.
here is the controller:
@super = params[:supermarkets]
@superm = []
@super.each do |s|
@superm << Company.find(s).abbr
end
@cuts = params[:cuts]
@prods = params[:products]
@cortesGraph = []
@cortess.to_a.each do |c|
@cortesGraph << "#{RawData.find_by_real_cut(c).cuts}"
end
The objects @superm,@cuts and @products arent receving more than 1 value in the array, is a routing problem or a option i have missed in the form_remote_tag?
And update to simplyfy, what actually is still happening is this:
This Works:
<%= form_tag reporte_client_reports_path do%>
This doesn't:
<%= form_tag reporte_client_reports_path,:remote=>true do%>
The problem is that :remote is not sending my params as array it send all data as 1 var :s
I resolved in functional way, but there might be something very weird with this in my controller:
if request.xhr?
@super = params[:supermercados].to_s.split(",")
@cortess = params[:cortes].to_s.split(",")
@prods = params[:productos].to_s.split(",")
end
精彩评论