开发者

rails multiple form actions with ajax

开发者 https://www.devze.com 2023-01-14 23:10 出处:网络
I have a basic Rails form like so: <%= form_for @person do |f| %> <%= f.label :first_name %>:

I have a basic Rails form like so:

<%= form_for @person do |f| %>
    <%= f.label :first_name %>:
    <%= f.text_field :first_name %><br />

    <%= f.label :last_name %>:
    <%= f.text_field :last_name %><br />

    <%= f.submit %>
  <% end %>

How could I optionally send the form information to another an entirely different controller via ajax?... two buttons (bypassing the main controller) The reason being... the user could make the booking... or simply include the same information to a inquiry form which doesn't touch the booking controller/model.

Bas开发者_如何学Cically I want all the form objects, but just sent to another controller?

Something like link_to_remote + all my form contents.


I think what you need is form with two buttons. like one button is for booking and another is inquiry. if that's case then try following link it explains well ..

Two submit buttons with form_remote_tag

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号