From 260d6f112a0ffdbe03e6f5051504cb441c1e94cd Mon Sep 17 00:00:00 2001 From: npezza93 Date: Tue, 13 Jun 2017 10:54:35 -0400 Subject: Change `form_with` to generates ids by default When `form_with` was introduced we disabled the automatic generation of ids that was enabled in `form_for`. This usually is not an good idea since labels don't work when the input doesn't have an id and it made harder to test with Capybara. You can still disable the automatic generation of ids setting `config.action_view.form_with_generates_ids` to `false.` --- actionview/CHANGELOG.md | 11 + actionview/lib/action_view/helpers/form_helper.rb | 27 +- actionview/lib/action_view/helpers/tags/base.rb | 7 +- .../helpers/tags/collection_check_boxes.rb | 1 - .../helpers/tags/collection_radio_buttons.rb | 1 - actionview/lib/action_view/helpers/tags/label.rb | 4 - actionview/lib/action_view/helpers/tags/select.rb | 2 +- actionview/lib/action_view/railtie.rb | 9 + .../test/template/form_helper/form_with_test.rb | 408 +++++++++++---------- 9 files changed, 245 insertions(+), 225 deletions(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index c700cb72ec..e8198926a5 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,14 @@ +* Change `form_with` to generates ids by default. + + When `form_with` was introduced we disabled the automatic generation of ids + that was enabled in `form_for`. This usually is not an good idea since labels don't work + when the input doesn't have an id and it made harder to test with Capybara. + + You can still disable the automatic generation of ids setting `config.action_view.form_with_generates_ids` + to `false.` + + *Nick Pezza* + * Fix issues with `field_error_proc` wrapping `optgroup` and select divider `option`. Fixes #31088 diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb index 6d2ace8cf8..167ad06ff5 100644 --- a/actionview/lib/action_view/helpers/form_helper.rb +++ b/actionview/lib/action_view/helpers/form_helper.rb @@ -478,6 +478,8 @@ module ActionView mattr_accessor :form_with_generates_remote_forms, default: true + mattr_accessor :form_with_generates_ids, default: true + # Creates a form tag based on mixing URLs, scopes, or models. # # # Using just a URL: @@ -640,16 +642,6 @@ module ActionView # # Where @document = Document.find(params[:id]). # - # When using labels +form_with+ requires setting the id on the field being - # labelled: - # - # <%= form_with(model: @post) do |form| %> - # <%= form.label :title %> - # <%= form.text_field :title, id: :post_title %> - # <% end %> - # - # See +label+ for more on how the +for+ attribute is derived. - # # === Mixing with other form helpers # # While +form_with+ uses a FormBuilder object it's possible to mix and @@ -746,7 +738,6 @@ module ActionView # end def form_with(model: nil, scope: nil, url: nil, format: nil, **options) options[:allow_method_names_outside_object] = true - options[:skip_default_ids] = true if model url ||= polymorphic_path(model, format: format) @@ -1044,16 +1035,6 @@ module ActionView # or model is yielded, so any generated field names are prefixed with # either the passed scope or the scope inferred from the :model. # - # When using labels +fields+ requires setting the id on the field being - # labelled: - # - # <%= fields :comment do |fields| %> - # <%= fields.label :body %> - # <%= fields.text_field :body, id: :comment_body %> - # <% end %> - # - # See +label+ for more on how the +for+ attribute is derived. - # # === Mixing with other form helpers # # While +form_with+ uses a FormBuilder object it's possible to mix and @@ -1072,7 +1053,6 @@ module ActionView # FormOptionsHelper#collection_select and DateHelper#datetime_select. def fields(scope = nil, model: nil, **options, &block) options[:allow_method_names_outside_object] = true - options[:skip_default_ids] = true if model scope ||= model_name_from_record_or_class(model).param_key @@ -1676,7 +1656,7 @@ module ActionView def initialize(object_name, object, template, options) @nested_child_index = {} @object_name, @object, @template, @options = object_name, object, template, options - @default_options = @options ? @options.slice(:index, :namespace, :skip_default_ids, :allow_method_names_outside_object) : {} + @default_options = @options ? @options.slice(:index, :namespace, :allow_method_names_outside_object) : {} convert_to_legacy_options(@options) @@ -1985,7 +1965,6 @@ module ActionView # See the docs for the ActionView::FormHelper.fields helper method. def fields(scope = nil, model: nil, **options, &block) options[:allow_method_names_outside_object] = true - options[:skip_default_ids] = true convert_to_legacy_options(options) diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb index 8934a9894c..a8940e71a9 100644 --- a/actionview/lib/action_view/helpers/tags/base.rb +++ b/actionview/lib/action_view/helpers/tags/base.rb @@ -15,7 +15,6 @@ module ActionView @object_name.sub!(/\[\]$/, "") || @object_name.sub!(/\[\]\]$/, "]") @object = retrieve_object(options.delete(:object)) - @skip_default_ids = options.delete(:skip_default_ids) @allow_method_names_outside_object = options.delete(:allow_method_names_outside_object) @options = options @@ -97,7 +96,7 @@ module ActionView index = name_and_id_index(options) options["name"] = options.fetch("name") { tag_name(options["multiple"], index) } - unless skip_default_ids? + if generate_ids? options["id"] = options.fetch("id") { tag_id(index) } if namespace = options.delete("namespace") options["id"] = options["id"] ? "#{namespace}_#{options['id']}" : namespace @@ -183,8 +182,8 @@ module ActionView end end - def skip_default_ids? - @skip_default_ids + def generate_ids? + ActionView::Helpers::FormHelper.form_with_generates_ids end end end diff --git a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb index 455442178e..021a6c0c0c 100644 --- a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb +++ b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb @@ -12,7 +12,6 @@ module ActionView def check_box(extra_html_options = {}) html_options = extra_html_options.merge(@input_html_options) html_options[:multiple] = true - html_options[:skip_default_ids] = false @template_object.check_box(@object_name, @method_name, html_options, @value, nil) end end diff --git a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb index 16d37134e5..b25e124a15 100644 --- a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb +++ b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb @@ -11,7 +11,6 @@ module ActionView class RadioButtonBuilder < Builder # :nodoc: def radio_button(extra_html_options = {}) html_options = extra_html_options.merge(@input_html_options) - html_options[:skip_default_ids] = false @template_object.radio_button(@object_name, @method_name, @value, html_options) end end diff --git a/actionview/lib/action_view/helpers/tags/label.rb b/actionview/lib/action_view/helpers/tags/label.rb index 56b48bbd62..02bd099784 100644 --- a/actionview/lib/action_view/helpers/tags/label.rb +++ b/actionview/lib/action_view/helpers/tags/label.rb @@ -75,10 +75,6 @@ module ActionView def render_component(builder) builder.translation end - - def skip_default_ids? - false # The id is used as the `for` attribute. - end end end end diff --git a/actionview/lib/action_view/helpers/tags/select.rb b/actionview/lib/action_view/helpers/tags/select.rb index 345484ba92..fcb2d49bc3 100644 --- a/actionview/lib/action_view/helpers/tags/select.rb +++ b/actionview/lib/action_view/helpers/tags/select.rb @@ -8,7 +8,7 @@ module ActionView @choices = block_given? ? template_object.capture { yield || "" } : choices @choices = @choices.to_a if @choices.is_a?(Range) - @html_options = html_options.except(:skip_default_ids, :allow_method_names_outside_object) + @html_options = html_options.except(:allow_method_names_outside_object) super(object_name, method_name, template_object, options) end diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb index b22347c55c..6ac332acbb 100644 --- a/actionview/lib/action_view/railtie.rb +++ b/actionview/lib/action_view/railtie.rb @@ -28,6 +28,15 @@ module ActionView end end + initializer "action_view.form_with_generates_ids" do |app| + ActiveSupport.on_load(:action_view) do + form_with_generates_ids = app.config.action_view.delete(:form_with_generates_ids) + unless form_with_generates_ids.nil? + ActionView::Helpers::FormHelper.form_with_generates_ids = form_with_generates_ids + end + end + end + initializer "action_view.logger" do ActiveSupport.on_load(:action_view) { self.logger ||= Rails.logger } end diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index c7d49070ce..ad23d31d41 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -314,17 +314,45 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", "create-post", method: "patch") do "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" + end + + assert_dom_equal expected, output_buffer + end + + def test_form_with_not_outputting_ids + old_value = ActionView::Helpers::FormHelper.form_with_generates_ids + ActionView::Helpers::FormHelper.form_with_generates_ids = false + + form_with(model: @post, id: "create-post") do |f| + concat f.label(:title) { "The Title" } + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + concat f.select(:category, %w( animal economy sports )) + concat f.submit("Create post") + end + + expected = whole_form("/posts/123", "create-post", method: "patch") do + "" \ "" \ "" \ "" \ "" \ "" \ - "" \ - "" \ - "" + "" end assert_dom_equal expected, output_buffer + ensure + ActionView::Helpers::FormHelper.form_with_generates_ids = old_value end def test_form_with_only_url_on_create @@ -335,7 +363,7 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do '' \ - '' + '' end assert_dom_equal expected, output_buffer @@ -349,7 +377,7 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123") do '' \ - '' + '' end assert_dom_equal expected, output_buffer @@ -361,7 +389,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123") do - '' + '' end assert_dom_equal expected, output_buffer @@ -373,7 +401,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: :patch) do - '' + '' end assert_dom_equal expected, output_buffer @@ -391,8 +419,8 @@ class FormWithActsLikeFormForTest < FormWithTest end.new form_with(model: obj, scope: "other_name", url: "/", id: "edit-other-name") do |f| - assert_dom_equal '', f.hidden_field(:private_property) - assert_dom_equal '', f.hidden_field(:protected_property) + assert_dom_equal '', f.hidden_field(:private_property) + assert_dom_equal '', f.hidden_field(:protected_property) end end @@ -459,7 +487,7 @@ class FormWithActsLikeFormForTest < FormWithTest "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -557,7 +585,7 @@ class FormWithActsLikeFormForTest < FormWithTest "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -587,7 +615,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", "create-post", method: "patch", multipart: true) do - "" + "" end assert_dom_equal expected, output_buffer @@ -601,7 +629,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch", multipart: true) do - "" + "" end assert_dom_equal expected, output_buffer @@ -640,7 +668,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/44", method: "patch") do - "" \ + "" \ "" end @@ -658,10 +686,10 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", "create-post", method: "patch") do "" \ - "" \ - "" \ + "" \ + "" \ "" \ - "" \ + "" \ "" end @@ -676,10 +704,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post", method: "delete") do - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -693,10 +721,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post", method: "delete") do - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -710,7 +738,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/search", "search-post", method: "get") do - "" + "" end assert_dom_equal expected, output_buffer @@ -724,10 +752,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post", method: "patch") do - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -744,10 +772,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post", method: "patch", local: true) do - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -761,7 +789,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", skip_enforcing_utf8: true) do - "" + "" end assert_dom_equal expected, output_buffer @@ -773,7 +801,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", skip_enforcing_utf8: false) do - "" + "" end assert_dom_equal expected, output_buffer @@ -787,10 +815,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post") do - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -806,10 +834,10 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", method: "patch") do "" \ - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -823,10 +851,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -841,7 +869,7 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", method: "patch") do "
" \ - "
" \ + "
" \ "" end @@ -859,7 +887,7 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", method: "patch") do "
" \ - "
" \ + "
" \ "" end @@ -947,7 +975,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: :patch) do - '' + '' end assert_dom_equal expected, output_buffer @@ -967,7 +995,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form do - '' + '' end assert_dom_equal expected, output_buffer @@ -982,7 +1010,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1002,7 +1030,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form do - "" + "" end assert_dom_equal expected, output_buffer @@ -1017,8 +1045,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" \ - "" + "" \ + "" end assert_dom_equal expected, output_buffer @@ -1033,8 +1061,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" \ - "" + "" \ + "" end assert_dom_equal expected, output_buffer @@ -1048,7 +1076,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1062,7 +1090,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1076,7 +1104,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1090,7 +1118,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1104,7 +1132,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1124,9 +1152,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end + whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1143,8 +1171,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1170,9 +1198,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1189,9 +1217,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1208,8 +1236,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1226,8 +1254,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1244,9 +1272,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1264,9 +1292,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1285,11 +1313,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1312,11 +1340,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1339,10 +1367,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1365,11 +1393,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1388,11 +1416,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1412,11 +1440,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1435,9 +1463,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1456,10 +1484,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1474,7 +1502,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + '' end assert_dom_equal expected, output_buffer @@ -1491,11 +1519,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1512,11 +1540,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1547,11 +1575,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1570,10 +1598,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1590,8 +1618,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1607,8 +1635,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1630,8 +1658,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1716,18 +1744,18 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' + '' \ + '' \ + '' \ + '' \ + '' \ + '' \ + '' \ + '' \ + '' \ + '' \ + '' \ + '' end assert_dom_equal expected, output_buffer @@ -1743,7 +1771,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + '' end assert_dom_equal expected, output_buffer @@ -1757,10 +1785,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" assert_dom_equal expected, output_buffer end @@ -1773,10 +1801,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" assert_dom_equal expected, output_buffer end @@ -1789,10 +1817,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" assert_dom_equal expected, output_buffer end @@ -1805,10 +1833,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" assert_dom_equal expected, output_buffer end @@ -1821,10 +1849,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" assert_dom_equal expected, output_buffer end @@ -1837,10 +1865,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" assert_dom_equal expected, output_buffer end @@ -1852,7 +1880,7 @@ class FormWithActsLikeFormForTest < FormWithTest end assert_dom_equal "" \ - "", + "", output_buffer end @@ -1863,7 +1891,7 @@ class FormWithActsLikeFormForTest < FormWithTest end assert_dom_equal "" \ - "", + "", output_buffer end @@ -1882,10 +1910,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", "create-post", method: "patch") do - "" \ - "" \ + "" \ + "" \ "" \ - "" + "" end assert_dom_equal expected, output_buffer @@ -1902,9 +1930,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", "create-post", method: "patch") do - "" \ - "" \ - "" + "" \ + "" \ + "" end assert_dom_equal expected, output_buffer @@ -1918,7 +1946,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1942,9 +1970,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "
" \ - "
" \ - "
" + "
" \ + "
" \ + "
" end assert_dom_equal expected, output_buffer @@ -1961,9 +1989,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "
" \ - "
" \ - "
" + "
" \ + "
" \ + "
" end assert_dom_equal expected, output_buffer @@ -1980,7 +2008,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "
" + "
" end assert_dom_equal expected, output_buffer @@ -1995,7 +2023,7 @@ class FormWithActsLikeFormForTest < FormWithTest concat f.text_field(:title) end - expected = "
" + expected = "
" assert_dom_equal expected, output_buffer end @@ -2007,7 +2035,7 @@ class FormWithActsLikeFormForTest < FormWithTest concat f.text_field(:title) end - expected = "
" + expected = "
" assert_dom_equal expected, output_buffer end @@ -2020,9 +2048,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "
" \ - "
" \ - "
" + "
" \ + "
" \ + "
" assert_dom_equal expected, output_buffer end -- cgit v1.2.3 From 36ac675d2af5838c81afbd7c95b2e403e6366ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 25 Nov 2017 11:49:01 -0500 Subject: Make form_with_generates_ids default in Rails 5.2 When the defaults being loaded are the 5.0 or 5.1 we disable generation of ids with form_with. --- actionview/lib/action_view/railtie.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb index 6ac332acbb..73dfb267bb 100644 --- a/actionview/lib/action_view/railtie.rb +++ b/actionview/lib/action_view/railtie.rb @@ -22,9 +22,7 @@ module ActionView initializer "action_view.form_with_generates_remote_forms" do |app| ActiveSupport.on_load(:action_view) do form_with_generates_remote_forms = app.config.action_view.delete(:form_with_generates_remote_forms) - unless form_with_generates_remote_forms.nil? - ActionView::Helpers::FormHelper.form_with_generates_remote_forms = form_with_generates_remote_forms - end + ActionView::Helpers::FormHelper.form_with_generates_remote_forms = form_with_generates_remote_forms end end -- cgit v1.2.3