How to add an html id to a form_for tag in rails?

前端 未结 3 1251
暗喜
暗喜 2021-02-11 19:36

I\'m trying to add an id tag to a form that I\'m creating in rails. The beginning of the form has the following code:

<%= form_for(@user) do |f| %>
         


        
相关标签:
3条回答
  • 2021-02-11 20:03

    This is new syntax

    <%= form_for @user, html: {id: "my_form"} do |f| %> <% end %>

    0 讨论(0)
  • 2021-02-11 20:04

    One more way: <%= form_for @user, html: {id: :form_id } do |f| %>

    0 讨论(0)
  • 2021-02-11 20:16

    try this <%= form_for @user, :url => "controller action url", :html => {:id => "Blabla"} do |f| %>

    EDIT: If you don't want custom action URL then you can use this as well <%= form_for @user, html: {id: "BlaBla"} do |f| %>

    0 讨论(0)
提交回复
热议问题