How to use two submit_tag in a form?

any idea to use 2 submit_tag in a from ,and the action also should be
two…

like below(absolutely below code will not work ,but i want like that)…

<%=start_form_tag %>

something here

<%=submit_tag “submit1” ,:action=>‘action1’ %>
<%=submit_tag “submit2” ,:action=>‘action2’%>
<%=end_form_tag%>

not sure if that’s the perfect way to do it, but it worked fine for me:

in the onclick of submit_tag set (with prototy.js func in this case) the
forms action and then call submit like this:

<%= submit_tag “Upload Image”, :onclick =>
“$(‘form_id’).action=’#{article_images_path(article)}’;$(‘form_id’).submit();”
%>

replace form_id with id of your form and articles_image_path with
whatever you want to call

Thorsten M. wrote:

<%= submit_tag “Upload Image”, :onclick =>
“$(‘form_id’).action=’#{article_images_path(article)}’;$(‘form_id’).submit();”
%>

replace form_id with id of your form and articles_image_path with
whatever you want to call

thank you for quick reply

unknown aciton error is occured

unknown aciton error is occured

then please post the code and the error in more detail
nobody can know, what’s in your controller and what you call

this
$(‘form_id’).action=’#{article_images_path(article)}’
is only an example, you must replace article_images_path
with an url that points to your controller/action
as you would use it eg in a link_to

Pokkai D. wrote:

Thorsten M. wrote:

unknown aciton error is occured

then please post the code and the error in more detail
nobody can know, what’s in your controller and what you call

this
$(‘form_id’).action=’#{article_images_path(article)}’
is only an example, you must replace article_images_path
with an url that points to your controller/action
as you would use it eg in a link_to

actually the eruby function start_form_tag is a deprecate from form_tag
the format is
“form_tag(url_for_options = {}, options = {}, *parameters_for_url,
&block)”
how should i write id name in <%start_form_tag %>

Not exactly what you asked for, but you could check params[:commit] in
the controller to see which submit was clicked.

<% form_for(:my_model, :url => my_models_path) do |f| %>
<%= submit_tag “submit1” %>

<%= submit_tag “submit2” %>
<% end %>

class MyModelsController < ApplicationController
def create
if params[:commit] == “submit1”
# do something
else
# do something else
end
end
end

On Nov 21, 4:18 am, Pokkai D. [email protected]

You can’t have one form inside another. You can have two forms within a
single page, just not one imbedded inside another. I have tried it:

http://www.ruby-forum.com/topic/113330#new

-S

Thorsten M. wrote:

unknown aciton error is occured

then please post the code and the error in more detail
nobody can know, what’s in your controller and what you call

this
$(‘form_id’).action=’#{article_images_path(article)}’
is only an example, you must replace article_images_path
with an url that points to your controller/action
as you would use it eg in a link_to

thank you for reply

actually i don’t know html very well

i want to make a form ,which should have 2 submit tag
if i click save then it should got to(with all params values)
action save
if i click update then it should got to(with all params values)
action update

<%=start_form_tag %>

something here

<%=submit_tag “Save” ,:action=>‘save’ %>
<%=submit_tag “Update” ,:action=>‘update’%>
<%=end_form_tag%>

can you make a (just a )small example for my problem