From b64467ecad9cfa450ec172f59d656c3baced57e6 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 18 Dec 2016 12:14:24 +0100 Subject: Make attributes output in html opt-in. By using `except` any option provided to `form_with` would become an html attribute unless explicitly opted out. This proved annoying when adding new internal keys in the options hash and seeing them pop up in the html output. Prevent this by inverting the `except` to `slice` out the keys we want to allow becoming html attributes, like id and class. --- actionview/lib/action_view/helpers/form_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib/action_view') diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb index 6c632b8e75..a94a28306a 100644 --- a/actionview/lib/action_view/helpers/form_helper.rb +++ b/actionview/lib/action_view/helpers/form_helper.rb @@ -1492,7 +1492,7 @@ module ActionView private def html_options_for_form_with(url_for_options = nil, model = nil, html: {}, local: false, skip_enforcing_utf8: false, **options) - html_options = options.except(:index, :include_id, :skip_default_ids, :builder).merge(html) + 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 -- cgit v1.2.3