1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/lib
Kasper Timm Hansen 67f81cc72d Add form_with to unify form_tag/form_for. (#26976)
* Add form_with to unify form_tag/form_for.

`form_tag` and `form_for` serve very similar use cases. This
PR unifies that usage such that `form_with` can output just
the opening form tag akin to `form_tag` and can just work with
a url, for instance.

`form_with` by default doesn't attach class or id to the form —
removing them on fields is moved out to a default revisiting PR later.

Ported over old tests where applicable to ensure maximum coverage,
but left some commented out because they don't yet apply (e.g.
`fields_for` later being replaced by `fields`).

[ Kasper Timm Hansen & Marek Kirejczyk ]

* Add fields DSL method.

Strips `_for` and requires models passed as a keyword argument.

* Document form_with.

Graft the `form_for` docs: rewrite, revise and expand where
needed.

Also test that a `format` isn't used when an explicit URL
is passed.

* Enable remote by default.

Brand new world! Forms submit via XHRs by default, woah.

* Invert `include_id` to `skip_id`.

`skip_id: true` reads better than `include_id: false` (since the
`include_id` default is true).

* Invert `remote` to `local`.

Since forms are remote by default, the option name makes more sense
as `local: true`.

* Invert `enforce_utf8` to `skip_enforcing_utf8`.

* Refer to the brand spanking new rails-ujs.

Soon to be bundled in Rails proper, so jquery-ujs is out.

* Make `form_with` a bit more composed.

The flow is still not quite what it should be because the legacy
methods and these new ones pull at opposite ends.

Lots of options have been renamed, so now the new pieces don't fit
in so well.

I'll try to work on this in later commits after this PR (it's likely
there's a much better way to structure this whole part of Action View).
2016-11-21 20:48:51 +01:00
..
action_view Add form_with to unify form_tag/form_for. (#26976) 2016-11-21 20:48:51 +01:00
action_view.rb applies new string literal convention in actionview/lib 2016-08-06 18:48:35 +02:00