Forum: Ruby on Rails Cant identify Multiple Submit Buttons in form_remote_tag

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
535eb0617348da39410f63de18ae6f22?d=identicon&s=25 Surjya Hazarika (prasad)
on 2005-12-06 12:59
Hi,
   Like Derek, I also found a bug in the form_remote_tag function.
Whenever there are two or more Submit buttons, rails is not able to
identify as to which Submit button has been clicked. On the otherhand
Non-AJAX forms work perfectly. If possible please throw some light into
this.

regards..
Prasad
Tr S/W Engineer,
Genie Interactive
408ef3d328434279d828e7aa2d92b7a8?d=identicon&s=25 Neha Chopra (neha_rohan)
on 2008-01-29 18:52
Surjya Hazarika wrote:
> Hi,
>    Like Derek, I also found a bug in the form_remote_tag function.
> Whenever there are two or more Submit buttons, rails is not able to
> identify as to which Submit button has been clicked. On the otherhand
> Non-AJAX forms work perfectly. If possible please throw some light into
> this.
>
> regards..
> Prasad
> Tr S/W Engineer,
> Genie Interactive

Hi,
If you have a form that calls for submisions to various functions then
try the following code in your own way.
<%= hidden_field_tag('commit', 'add_another_criteria') %>
  <%= submit_tag('Add Another Search Term', :name => '_commit') %>
  <%= submit_tag('Generate Report', :name => '_commit',
                 :onclick => "Form.getInputs(this.form, null,
'commit')[0].value = 'Generate Report'") %>

Then  in your method, check the params passed for each button click and
depending on that you can do the server side programming.

Hope this helps.
This topic is locked and can not be replied to.