rails--rails/actionview/test
Sean Doyle 9af9458396 Consistently render `button_to` as `<button>`
Prior to this commit, the
[ActionView::Helpers::UrlHelper#button_to][button_to] helper rendered
`<input type="submit">` elements when passed its contents as a String
argument, and rendered `<button type="submit">` elements when passed its
contents as a block.

This difference is subtle, and might lead to surprises.

Additionally, a `<form>` element's submitter can encode a `name`/`value`
pairing, which will be submitted as part of the request. When
`button_to` renders an `<input type="submit">` element, the "button"
content is rendered as a `[value]` attribute, which prevents any
meaningful data from being encoded.

Since it's a single `<button>` or `<input type="submit">` within a
`<form>`, missing out on that opportunity to encode information might
not be a show stopper, but ensuring that a `<button>` element is
rendered _without_ a default `[value]` attribute enables applications to
encode additional information that can be accessed JavaScript as
`element.value`, instead of a workaround like
`element.getAttribute("data-value")`.

Support rendering `input` elements with button_to
---

To support the original behavior of `button_to` rendering `<input
type="submit">` elements when invoked _without_ a block, expose the
`app.config.button_to_generates_button_tag` configuration flag.

By default, it's set to `true` and ensures that all `button_to` calls
render `<button>` elements. To revert to the original behavior, set it
to `false`.

[button_to]: https://api.rubyonrails.org/v6.0/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to

Co-authored-by: Dusan Orlovic <duleorlovic@gmail.com>
2020-12-28 19:33:05 -05:00
..
actionpack Remove an unused Action View test fixture 2020-11-01 23:25:29 +00:00
activerecord Fix `SELECT COUNT` queries when rendering ActiveRecord collections (#40870) 2020-12-18 15:58:11 -05:00
fixtures Remove an unused Action View test fixture 2020-11-01 23:25:29 +00:00
lib Include layout when rendering objects from controllers 2020-10-14 11:49:45 -06:00
template Consistently render `button_to` as `<button>` 2020-12-28 19:33:05 -05:00
ujs Merge pull request #40348 from rails/no-erb-in-ujsserver 2020-11-30 01:11:28 -08:00
abstract_unit.rb Merge pull request #39939 from Shopify/link-preload-headers 2020-08-17 08:37:22 -04:00
active_record_unit.rb Module#const_set is a public method 2020-09-15 17:19:37 +09:00