instance method html_options_for_form_with

Ruby on Rails 6.0.6

Since v5.2.8.1 Private

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

html_options_for_form_with(url_for_options = nil, model = nil, html: {}, local: !form_with_generates_remote_forms, skip_enforcing_utf8: nil, **options)

No documentation comment.

Parameters

url_for_options opt = nil
model opt = nil
html key = {}
local key = !form_with_generates_remote_forms
skip_enforcing_utf8 key = nil
options keyrest
Source
# File actionview/lib/action_view/helpers/form_helper.rb, line 1527
        def html_options_for_form_with(url_for_options = nil, model = nil, html: {}, local: !form_with_generates_remote_forms,
          skip_enforcing_utf8: nil, **options)
          html_options = options.slice(:id, :class, :multipart, :method, :data).merge(html)
          html_options[:method] ||= :patch if model.respond_to?(:persisted?) && model.persisted?
          html_options[:enforce_utf8] = !skip_enforcing_utf8 unless skip_enforcing_utf8.nil?

          html_options[:enctype] = "multipart/form-data" if html_options.delete(:multipart)

          # The following URL is unescaped, this is just a hash of options, and it is the
          # responsibility of the caller to escape all the values.
          html_options[:action] = url_for(url_for_options || {})
          html_options[:"accept-charset"] = "UTF-8"
          html_options[:"data-remote"] = true unless local

          html_options[:authenticity_token] = options.delete(:authenticity_token)

          if !local && html_options[:authenticity_token].blank?
            html_options[:authenticity_token] = embed_authenticity_token_in_remote_forms
          end

          if html_options[:authenticity_token] == true
            # Include the default authenticity_token, which is only generated when it's set to nil,
            # but we needed the true value to override the default of no authenticity_token on data-remote.
            html_options[:authenticity_token] = nil
          end

          html_options.stringify_keys!
        end

Defined in actionview/lib/action_view/helpers/form_helper.rb line 1527 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Helpers::FormHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close