mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge PR #43416
This commit is contained in:
commit
846f9e9595
3 changed files with 16 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
* Support `fields model: [@nested, @model]` the same way as `form_with model:
|
||||
[@nested, @model]`.
|
||||
|
||||
*Sean Doyle*
|
||||
|
||||
* Infer HTTP verb `[method]` from a model or Array with model as the first
|
||||
argument to `button_to` when combined with a block:
|
||||
|
||||
|
|
|
@ -1078,6 +1078,7 @@ module ActionView
|
|||
options[:skip_default_ids] = !form_with_generates_ids
|
||||
|
||||
if model
|
||||
model = model.last if model.is_a?(Array)
|
||||
scope ||= model_name_from_record_or_class(model).param_key
|
||||
end
|
||||
|
||||
|
|
|
@ -2065,6 +2065,16 @@ class FormWithActsLikeFormForTest < FormWithTest
|
|||
assert_dom_equal expected, output_buffer
|
||||
end
|
||||
|
||||
def test_fields_with_only_object_array
|
||||
output_buffer = fields(model: [@post, @comment]) do |f|
|
||||
concat f.text_field(:name)
|
||||
end
|
||||
|
||||
expected = %(<input type="text" value="new comment" name="comment[name]" id="comment_name" />)
|
||||
|
||||
assert_dom_equal expected, output_buffer
|
||||
end
|
||||
|
||||
def test_fields_object_with_bracketed_name
|
||||
output_buffer = fields("author[post]", model: @post) do |f|
|
||||
concat f.label(:title)
|
||||
|
|
Loading…
Reference in a new issue