instance method
id
Ruby on Rails 8.1.2
Since v7.0.10Signature
id()
Generate an HTML id attribute value.
return the <form> element’s id attribute.
<%= form_with model: @article 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.
Source
# File actionview/lib/action_view/helpers/form_helper.rb, line 1757
def id
options.dig(:html, :id) || options[:id]
end
Defined in actionview/lib/action_view/helpers/form_helper.rb line 1757
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::FormBuilder