Commit Graph

131 Commits

Author SHA1 Message Date
Claas Z
def782dfeb
Clarified requirements for keys in nested structures 2022-04-14 17:50:05 +02:00
Jesse Sousa
27a2129929
Fix typo 2022-03-13 21:07:06 -03:00
Jonathan Hefner
031f7af1d6 Improve fields_for helper sections [ci-skip]
Prior to this commit, there were two sections in the Form Helpers guide
with the same heading "The `fields_for` Helper".

This commit differentiates those two headings, and makes some minor
improvements to both sections for clarity.
2022-02-14 16:28:53 -06:00
Jonathan Hefner
4ae7acf00d Fix typos [ci-skip] 2022-02-13 13:07:51 -06:00
Caleb Stevens
8efd634cab Fix boolean error in form helpers guide 2021-11-24 01:01:53 -08:00
Alex Ghiculescu
b8ee5732db Simplify singular resource example
This:

```ruby
resource :geocoder
```

and this:

```ruby
  resource :geocoder
  resolve('Geocoder') { [:geocoder] }
```

create exactly the same routes. Thus, it's better to show the simpler example rather than imply that both method calls are needed.

`resolve` is used for [polymorphic routes](https://guides.rubyonrails.org/routing.html#using-resolve) but isn't necessary in this example.
2021-03-28 18:38:51 -05:00
Alex Ghiculescu
0fba70c082 Clarify when enctype="multipart/form-data" gets added to forms [docs]
As noted in https://github.com/rails/rails/issues/41632 the docs for this are incorrect. The `enctype` attribute is automatically added anytime you make a form with a `file_field`.

Resolves https://github.com/rails/rails/issues/41632

Update actionview/lib/action_view/helpers/form_helper.rb

Co-authored-by: Petrik de Heus <petrik@deheus.net>
2021-03-10 13:09:46 -06:00
Tim Tilberg
6210565e14
Update name of input to fix typo 2021-01-21 23:48:32 -06:00
Sean Doyle
b8c9c9d06f Translate FormBuilder#button calls with formmethod:
When submitting a `<form>`, browsers will serialize the element that
initiated the submission as part of the [FormData][], including its
`name` and `value` attributes.

Browser support for `<form>` submission HTTP verbs is limited to `GET`
and `POST`. Rails currently works around this [limitation by
constructing `<input type="hidden" name="_method" value="VERB">` which
serializes `_method="VERB"` to the FormData][_method].

To support varied HTTP actions within the same form, this commit
intervenes when a `form.button formmethod: "..."` call is made during
form construction, and translates any `formmethod:` value to the
corresponding work-around version.

[FormData]: https://developer.mozilla.org/en-US/docs/Web/API/FormData
[_method]: https://edgeguides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark
[button-formmethod]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formmethod
2021-01-08 18:21:02 -05:00
Jonathan Hefner
cb0da4f817 Fix typos, grammar, and formatting [ci-skip]
This is a collection of minor superficial improvements.  It does not
include any significant content changes.
2020-12-28 12:05:53 -06:00
Petrik
0a583c73c1 Change form_with to generate non remote forms by default
`form_with` would generate a remote form by default.
This confused users because they were forced to handle remote requests.

All new 6.1 applications will generate non-remote forms by default.
When upgrading a 6.0 application you can enable remote forms by default by
setting `config.action_view.form_with_generates_remote_forms` to `true`.
2020-12-01 21:14:37 +01:00
Jonathan Hefner
3d82ed1b5a
Merge pull request #40377 from jonathanhefner/guide-form_helpers-_tag-helpers
Mention _tag helpers in Form Helpers guide [ci-skip]
2020-10-13 11:53:21 -05:00
Jonathan Hefner
93391a7468
Merge pull request #40339 from jonathanhefner/guide-form_helpers-grouped-options
Add Option Groups section to Form Helpers guide [ci-skip]
2020-10-13 11:52:33 -05:00
Jonathan Hefner
140cf5c9fe Mention _tag helpers in Form Helpers guide [ci-skip]
This adds mention of the `*_tag` helpers provided by `FormTagHelper`,
and directs the reader to the API documentation for more information.
2020-10-13 10:47:31 -05:00
Jonathan Hefner
a6c426d986 Rework Date and Time Form Helpers section [ci-skip]
This shifts the primary focus from the bare `select_*` helpers to the
equivalent `FormBuilder#*_select` helpers.  It also links all covered
helpers to their API documentation.
2020-10-08 16:33:14 -05:00
Jonathan Hefner
c4503a92e1 Link API documentation more in Form Helpers guide [ci-skip]
This links the first mention of each helper to its API documentation,
similar to a Wikipedia article.
2020-10-06 10:35:50 -05:00
Jonathan Hefner
34c43d579c Add Option Groups section to Form Helpers guide [ci-skip]
This introduces option groups, how they are specified, and how they are
rendered.
2020-10-05 16:53:56 -05:00
Sam Jewell
fb36561dd6
Fix when duplicate params are accumulated
The previous statement was not strictly true all of the time.
For example, an input named `person[phone_number[]]` does
not get automatically accumulated. Updated this to a statement
that is always true (even if it may not fully describe all possible
cases, such as perhaps nested forms).
2020-09-28 09:20:21 +01:00
Jonathan Hefner
d118875dce Unify coverage of collection helpers [ci skip]
Follow-up to #39344.

This adds back coverage of `collection_select`, adds new coverage of
`collection_radio_buttons`, revises existing coverage of
`collection_check_boxes`, and unifies these sections.
2020-06-04 01:13:04 -05:00
Jonathan Hefner
e86e0147dc Mention text_area helper [ci skip]
Follow-up to #39344.

Adds back mention of `text_area` helper.
2020-06-03 23:38:56 -05:00
Jonathan Hefner
612eb35a5a Prefer form builder methods in Form Helpers guide [ci skip]
The Form Helpers guide should encourage users to use `form_with` and
associated builder methods.  The lower-level `*_tag` methods are covered
by the API docs.

These changes also fix some discrepancies between code examples and
their descriptions.
2020-05-24 19:04:36 -05:00
Jamie
7817996fc4
Fix references in the form builders guide [ci skip]
I caught two references that seemed inconsistent:

1. In section 2.2 Binding a Form to an Object, the code snippet variable was called `form`, but in the bullet points below, it was referenced as `f`.
2. In section 6 Uploading Files, the references to the params hash returned by two different forms was incorrect.
2020-05-18 14:55:23 -04:00
Eileen M. Uchitelle
f4a72c4aed
Merge pull request #37885 from gwincr11/cg-document-checkboxes
Document working with association and checkboxes in a form
2020-03-31 10:34:32 -04:00
Cory Gwin @gwincr11
20ba3b8e0a Document working with association and checkboxes in a form
Motivation:
  - I frequently look for this in the docs then struggle to rememeber
  the name of the function I need to find in the api docs. Also I think
  other people may benefit from it being easier to find.

Changes:
  - Added a section about Collection Checkboxes to the docs.

Co-Authored-By: Eileen M. Uchitelle <eileencodes@users.noreply.github.com>
2020-03-31 10:31:05 -04:00
Jonathan Hefner
f2cedf9151 Update form examples [ci skip]
Convert examples to use `form_with` instead of `form_for` or `form_tag`,
which have been soft-deprecated.  Also rename form variable in examples
from `f` to `form`, as exemplified by 8ff7ca5d11.
2019-11-01 18:10:36 -05:00
Kasper Timm Hansen
eca6c273fe
[ci skip] switch eg. to proper e.g. 2019-10-07 02:18:36 +02:00
David
99557b7281
Fixed pluralization typo 2019-10-06 12:19:55 -04:00
mario
f60bc890ee correct information about record identification
The description claimed that `.new_record?` was used in `form_for` to derive the action and button text.
But in the code `.persisted?` is used for that purpose.

[ci skip]
2019-10-04 07:20:31 +02:00
Akshay Mohite
c27be3bf21
Added missing comment notation for the example of form_with in form_helpers.md documentation. [ci skip] 2019-08-01 18:09:35 +05:30
Sharang Dashputre
771973c13d url -> URL where apt except inside actionpack/ 2019-04-01 22:56:35 +05:30
Nathaniel Suchy
d9f1cc05b5 Update links and code examples in the guides to use HTTPS where the host supports it. 2019-03-06 15:21:07 -05:00
tkoyama1988
b1ca79514e Improve readability in form helpers guide [ci skip] 2018-09-17 17:30:25 +09:00
Nicolas Maloeuvre
e7a3df190c [ci skip] Typo in form helpers guide 2018-08-30 22:23:54 +02:00
bogdanvlviv
841fc1837b
Update "Action View Form Helpers" guide [ci skip] 2018-08-27 19:24:38 +03:00
bogdanvlviv
318ccf5b3b
Follow up #33523 [ci skip]
This commit is the next work after #33523.

Also, this commit removes mention about hidden `utf8` input. Since
form helpers don't generate this input by default since #32125.

Note that I also had created PR #31972 with improvements to
"Action View Form Helpers" guide, but I'll rebase it after merging the
current PR.
2018-08-27 15:39:49 +03:00
Aaron Patterson
de6a200f82
Merge pull request #33681 from minaslater/replace-white-and-blacklist
[ci skip] change all instances of blacklist and whitelist to denylist…
2018-08-23 13:20:22 -07:00
Mina Slater
f1d647aeff [ci skip] corrects more grammar awkwardness, replacing denylist with restricted list and consistently use permitted 2018-08-22 21:52:17 -05:00
Nick Schwaderer
cdee52079c Include form_with in form_helpers rails guide (#33523)
* Include form_with in form_helpers rails guide

* Include form_tag and form_for footnote

* Id and class attributes are not wrapped anymore

* Include note that all form_with forms are remote:true by default

* Underline most common use case of form_with is with arguments

* Form_with no longer accepts multiple hashes in form helper calls

* Review final sections

* Revert extra documentation

* Remove unnecessary link
2018-08-22 17:42:28 -07:00
Mina Slater
7bdf43daac [ci skip] fixes awkward grammar 2018-08-22 07:39:26 -05:00
Mina Slater
44da9eb3b9 [ci skip] change all instances of blacklist and whitelist to denylist and allowlist 2018-08-21 21:36:40 -05:00
Paul McMahon
978d486e4d Reference Active Storage instead of third-party libraries in guide
Paperclip has officially been deprecated, so we shouldn't mention it
anymore.

CarrierWave could still be referenced, as there are use cases where it
currently makes more sense, but for simplicity, I thought removing the
mention of third party libraries made sense. If we want to talk about
them, listing "alternatives" within the Active Storage guide could make
more sense.
2018-07-26 16:15:34 +09:00
Paul McMahon
7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
Anthony Crumley
258670244d Added a lot of Oxford commas
[ci skip] A regular expression was used to find a lot of missing Oxford
commas and add them.  The regular expression was as follows.

", ([a-zA-Z0-9.\`:'\"]+ ){1,6}(or|and) "
2018-05-10 12:46:06 -05:00
Eileen M. Uchitelle
53593a6636
Merge pull request #30474 from yhirano55/make_it_same_title_in_index_and_page
Make it same title in index and page [ci skip]
2017-12-13 10:23:14 -05:00
willnet
99f6722e86 [ci skip] Add a missing space before closing curly braces 2017-12-02 16:35:38 +09:00
Yoshiyuki Hirano
c330cc85a7 Update Form Helpers guide to fix example codes [ci skip]
* It looks that example codes are not based on actual output. So I've fixed it.
* Specifically:
  * There are no lines about utf-8 and authenticity_token.
  * The submit button doesn't have data-disabled-with attribute.
  * Each attribute order of html element is different from actual ones.
2017-09-17 07:35:36 +09:00
Yoshiyuki Hirano
10dfb153eb Make it same title in index and page [ci skip] 2017-08-31 01:49:50 +09:00
Rafael França
06580a4f97 Merge pull request #28432 from marksiemers/master
Update 'Building Complex Forms' with `inverse_of`
2017-04-20 19:58:26 -04:00
yuuji.yaginuma
2b82e96597 Remove datetime fields from helper list [ci skip]
The `datetime_field` is an alias of the `datetime_local_field`, there is
no helper to generate datetime fields.
Ref: #25469
2017-04-19 08:06:30 +09:00
marksiemers
dcd6ceb0c9 Update 'Building Complex Forms' with inverse_of
If the example for complex forms is implemented, ActiveRecord will prevent saving unless `inverse_of: :person` is added to the `has_many :addresses` association.
2017-03-15 12:38:49 -07:00