mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
be even more ambiguous about the order of generation of hidden input for check boxes in form helper guide
This commit is contained in:
parent
168e3958df
commit
485cd69a7b
1 changed files with 1 additions and 1 deletions
|
@ -683,7 +683,7 @@ This would result in +params[:addresses]+ being an array of hashes with keys +li
|
|||
|
||||
There's a restriction, however, while hashes can be nested arbitrarily, only one level of "arrayness" is allowed. Arrays can be usually replaced by hashes, for example instead of having an array of model objects one can have a hash of model objects keyed by their id, an array index or some other parameter.
|
||||
|
||||
WARNING: Array parameters do not play well with the +check_box+ helper. According to the HTML specification unchecked checkboxes submit no value. However it is often convenient for a checkbox to always submit a value. The +check_box+ helper fakes this by creating a second hidden input with the same name. If the checkbox is unchecked only the hidden input is submitted and if it is checked then both are submitted but the value submitted by the checkbox takes precedence. When working with array parameters this duplicate submission will confuse Rails since duplicate input names are how it decides when to start a new array element. It is preferable to either use +check_box_tag+ or to use hashes instead of arrays.
|
||||
WARNING: Array parameters do not play well with the +check_box+ helper. According to the HTML specification unchecked checkboxes submit no value. However it is often convenient for a checkbox to always submit a value. The +check_box+ helper fakes this by creating an auxiliary hidden input with the same name. If the checkbox is unchecked only the hidden input is submitted and if it is checked then both are submitted but the value submitted by the checkbox takes precedence. When working with array parameters this duplicate submission will confuse Rails since duplicate input names are how it decides when to start a new array element. It is preferable to either use +check_box_tag+ or to use hashes instead of arrays.
|
||||
|
||||
h4. Using Form Helpers
|
||||
|
||||
|
|
Loading…
Reference in a new issue