Skip to content

Minor doc improvement#1

Open
danlo wants to merge 12 commits intomainfrom
danlo/multiple-file-documentation
Open

Minor doc improvement#1
danlo wants to merge 12 commits intomainfrom
danlo/multiple-file-documentation

Conversation

@danlo
Copy link
Copy Markdown
Owner

@danlo danlo commented Nov 12, 2021

Added note indicating how to handle <input type="file" name="file[]" ...>

Summary

Other Information

seanpdoyle and others added 11 commits October 29, 2021 10:02
Match support for passing `authenticity_token:` in `form_with` and
`form_for` calls.

```ruby
button_to "Create", Post.new, authenticity_token: false
  # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button></form>

button_to "Create", Post.new, authenticity_token: true
  # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button><input type="hidden" name="form_token" value="abc123..." autocomplete="off" /></form>

button_to "Create", Post.new, authenticity_token: "secret"
  # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button><input type="hidden" name="form_token" value="secret" autocomplete="off" /></form>
```
Some background
---

By default, when a `<form>` is declared without an `[action]` attribute,
browsers will encode a `<form>`'s fields into the _current_ URL.

This can be useful for a `<form method="get">` that operates on the
current page. For example, when filtering search results, a form that
sorts:

```html
<form method="get">
  <button name="sort" value="desc">Most to least</button>
  <button name="sort" value="asc">Least to most</button>
</form>
```

can operate on a page that is filtered in another way by merging the
`?sort=asc` or `?sort=desc` values _into_ the existing page, which might
have the `?q=...` string set elsewhere.

The problem
---

Prior to this commit, none of the `<form>` construction variations
supported declaring a `<form>` without an `[action]` attribute.
`form_with`, `form_for`, and `form_tag` all default to `url_for({})`
when a `url:` or `action:` option is omitted.

The solution
---

Treat `url: false`, or `action: false` as an escape hatch to signal to
Action View that we don't need to transform the `model:` option or
argument into a Rails route.

Similarly, when calling `button_to` with `false` as the URL options
arguments will construct a `<form>` element without an `[action]`
attribute.
The `encoding` task has been removed a few years ago in
rails@510db97
Remove non-existing encoding task dependency
Support `<form>` elements without `[action]`
…-token

button_to: Support `authenticity_token:` option
…nt-direct-upload

Pass service_name param to DirectUploadsController
Added note indicating how to handle <input type="file" name="file[]" ...>
@danlo danlo force-pushed the danlo/multiple-file-documentation branch from 89aee77 to 1181006 Compare November 15, 2021 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet