I'm writing a rails app where users generate markers on a google map and then have the option to download them as .kml files. Thing is, I'm adding a feature to change the map to where they can see when they added specific markers to the map, with intervals. I want to use the same form as I did to previously download the .kml files but also add an extra submit button that will not do anything but run some controller logic. I originally had:
<%= form_tag customMapGenerate_path(@device, :format => 'kml'), :method => :get do %>
for my form_tag
How can I modify my two submit links:
<%= submit_tag 'Download KML' %>
<%= submit_tag 'Display on map' %>
to render KML and then not render anything (and stay on page) for both of the conditions below:
if(params[:commit] == "Download KML")
respond_to do |format|
format.kml
end
return
elsif(params[:commit] == "Display on map")
//simple ruby code
return
end
You can use button_tag
Remove the format from the form_tag
and it should give you something like this
<%= form_tag customMapGenerate_path(@device), :method => :get do %>
// your form here
<%= button_tag 'Download KML', value: 'kml', name: 'format' %>
<%= button_tag 'Display on map', value: 'html', name: 'format' %>
<% end %>
Then in you controller, you simply use the respond_to do |format|
to differenciate between your two types of response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With