method

id

Importance_2
v7.1.3.2 - Show latest stable - 0 notes - Class: ActionView::Helpers::FormBuilder
id() public

Generate an HTML id attribute value.

return the <form> element’s id attribute.

<%= form_for @post do |f| %>
  <%# ... %>

  <% content_for :sticky_footer do %>
    <%= form.button(form: f.id) %>
  <% end %>
<% end %>

In the example above, the :sticky_footer content area will exist outside of the <form> element. By declaring the form HTML attribute, we hint to the browser that the generated <button> element should be treated as the <form> element’s submit button, regardless of where it exists in the DOM.

Show source
Register or log in to add new notes.