Ruby on Rails : how to implement Cancel button in form_tag

后端 未结 4 1275
情书的邮戳
情书的邮戳 2021-02-07 15:28

I have a basic form using the form_tag helper working fine, but I want to add a cancel button, what is the syntax for doing this? I want the cancel button to appear as a button

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 15:56

    button_to seems a simple way to achieve the same, but it has to be put outside of the form itself, but that can easily be fixed with css.

    Also, to solve this in a more generic way (also working for editing nested resources on a resource that has not been persisted yet), you can create a separate form for the cancel that contains all the original values as hidden fields.

提交回复
热议问题