I want to have a form with a save and a cancel button. According to several Web site I should be able to put these two tags shown below in my form: <input type="submit" value="Save" name="savecancel"/> <input type="submit" value="Cancel" name="savecancel"/> I expect to be able to determine which button is clicked by testing ''params[:savecancel] == ''Cancel''. However, it doesn''t work, both values are in the request. I.e., Firebug reports the request as: _method=put&comment%5Bsummary%5D=Comment&comment%5Bdescription%5D=description4&tag_names=&savecancel=Save&savecancel=Cancel&previous_page=%2Ftasks%2Fsearch%3Fpage%3D2 And Webrick reports: Parameters: {"previous_page"=>"/tasks/search?page=2", "_method"=>"put", "action"=>"update", "savecancel"=>"Save", "id"=>"532", "controller"=>"comments", "tag_names"=>"", "taggable_id"=>"531", "comment"=>{"summary"=>"Comment", "description"=>"description4"}} Regardless of which button is actually clicked. Suggestions? Is Prototype.js messing this up? TIA, Jeffrey --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Is this in an ajax form? The ajax form will only detect the first submit tag. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Quoting Ryan Bigg (Radar) <radarlistener-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Is this in an ajax form? > > The ajax form will only detect the first submit tag. >Is a remote_form_for an AJAX form? If so, yes this is. Jeffrey --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yup. There''s your problem. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 16, 2008, at 5:16 PM, Jeffrey L. Taylor wrote:> I want to have a form with a save and a cancel button. According > to several > Web site I should be able to put these two tags shown below in my > form: > > <input type="submit" value="Save" name="savecancel"/> > <input type="submit" value="Cancel" name="savecancel"/> > > I expect to be able to determine which button is clicked by testing > ''params[:savecancel] == ''Cancel''. However, it doesn''t work, both > values are > in the request. I.e., Firebug reports the request as: > > _method=put&comment%5Bsummary%5D=Comment&comment%5Bdescription% > 5D=description4&tag_names=&savecancel=Save&savecancel=Cancel&previous_ > page=%2Ftasks%2Fsearch%3Fpage%3D2 > > And Webrick reports: > > Parameters: {"previous_page"=>"/tasks/search?page=2", > "_method"=>"put", "action"=>"update", "savecancel"=>"Save", > "id"=>"532", "controller"=>"comments", "tag_names"=>"", > "taggable_id"=>"531", "comment"=>{"summary"=>"Comment", > "description"=>"description4"}} > > Regardless of which button is actually clicked. Suggestions? Is > Prototype.js > messing this up?I found the same problem with image buttons. Prototype does not pass along the .x typically submitted by a normal HTML form. Suggestions? No one has been able to offer me any concrete ones. It''s a severe limitation in prototype (or perhaps XHR in general). -- gw --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 17 Jun 2008, at 03:07, Greg Willits wrote:>> I want to have a form with a save and a cancel button. According >> to several >> Web site I should be able to put these two tags shown below in my >> form: >> >> <input type="submit" value="Save" name="savecancel"/> >> <input type="submit" value="Cancel" name="savecancel"/> >> >> I expect to be able to determine which button is clicked by testing >> ''params[:savecancel] == ''Cancel''. However, it doesn''t work, both >> values are >> in the request. I.e., Firebug reports the request as: >> >> _method=put&comment%5Bsummary%5D=Comment&comment%5Bdescription% >> 5D >> =description4&tag_names=&savecancel=Save&savecancel=Cancel&previous_ >> page=%2Ftasks%2Fsearch%3Fpage%3D2 >> >> And Webrick reports: >> >> Parameters: {"previous_page"=>"/tasks/search?page=2", >> "_method"=>"put", "action"=>"update", "savecancel"=>"Save", >> "id"=>"532", "controller"=>"comments", "tag_names"=>"", >> "taggable_id"=>"531", "comment"=>{"summary"=>"Comment", >> "description"=>"description4"}} >> >> Regardless of which button is actually clicked. Suggestions? Is >> Prototype.js >> messing this up? > > I found the same problem with image buttons. Prototype does not pass > along the .x typically submitted by a normal HTML form. > > Suggestions? No one has been able to offer me any concrete ones. It''s > a severe limitation in prototype (or perhaps XHR in general).It''s something that you''ll have on all ajax frameworks, there are a few possible solutions to the problem: 1. http://www.rails.cz/articles/2007/07/13/ajax-forms-with-multiple-submit-buttons-bug 2. A cancel button is not something that should submit the form values in the first place, cancelling is just an action and not an update, so it''s better to just keep it a (either normal or ajax) link, i.e. <a href>. You can then style it to appear just like your submit button. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Quoting Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>:> > Quoting Ryan Bigg (Radar) <radarlistener-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > Is this in an ajax form? > > > > The ajax form will only detect the first submit tag. > > > > Is a remote_form_for an AJAX form? If so, yes this is. >I have been looking at del.icio.us which is where I stole the idea from. Using the Firebug extension for Firefox I can see the HTML and GET/POST requests and the responses. It''s interesting. The "form" isn''t really an HTML form, it''s a bunch of input tags. The cancel button does not make a request to the server. And the "form" isn''t replacing the content being altered, it''s still there but hidden, i.e., ''display: none'' style/attribute. Should be easy to delete the "form" and unhide the original content with some JavaScript. I don''t understand it all, but I have enough to explore. When I have something working I''ll write it up on my blog and post a link here. Jeffrey --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---