aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/form_helper.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add requireDavid Heinemeier Hansson2017-08-011-0/+1
|
* Move the direct_upload: true convenience option from the activestorage ↵David Heinemeier Hansson2017-07-311-1/+5
| | | | helper into actionview
* Use frozen string literal in actionview/Kir Shatrov2017-07-241-0/+2
|
* [Action View] require => require_relativeAkira Matsuda2017-07-011-6/+6
|
* Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-031-4/+2
|
* Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-8/+9
| | | | | | | | | | | | * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
* Add `form_with_generates_remote_forms` config.Kasper Timm Hansen2017-04-161-1/+3
| | | | | | | Allows users to not have remote forms by default, since there's more JS harness, e.g. bundling rails-ujs, otherwise. Also don't skip creating defaults file anymore. Sprockets isn't the only new config.
* Default embed_authenticity_token_in_remote_forms to nil.Kasper Timm Hansen2017-04-161-6/+8
| | | | | | | Effectively treat nil values as "auto", e.g. whatever a form helper chooses to interpret it as. But treat an explicitly assigned false value as disabling.
* Fix module name [ci skip]yuuji.yaginuma2017-04-151-10/+10
| | | | Replace `FormOptionHelper` to `FormOptionsHelper`.
* Close form_for tag in FormHelper API docsAlex Muller2017-04-131-2/+2
|
* do not mutate `object_name` of class in `fields_for`yuuji.yaginuma2016-12-271-1/+2
| | | | | | Since it affects the entire form, should not mutate `object_name` of class. Fixes #26931
* fields: support attributes not on model.Kasper Timm Hansen2016-12-181-0/+2
| | | | Ensure the support works like form_with.
* [ci skip] fields don't output ids by default anymore.Kasper Timm Hansen2016-12-181-2/+2
|
* form_with: allow methods outside the model.Kasper Timm Hansen2016-12-181-1/+13
| | | | | | | | Has the handy effect of making the initial examples in the form_with docs work too. Had to do some finagling such that form_with's without a scope didn't wrap their names in braces ala `[title]`.
* [ci skip] Replace remote with local in form_with doc.Kasper Timm Hansen2016-12-181-1/+1
| | | | Remote is gone, long live local.
* Make attributes output in html opt-in.Kasper Timm Hansen2016-12-181-1/+1
| | | | | | | | | | By using `except` any option provided to `form_with` would become an html attribute unless explicitly opted out. This proved annoying when adding new internal keys in the options hash and seeing them pop up in the html output. Prevent this by inverting the `except` to `slice` out the keys we want to allow becoming html attributes, like id and class.
* Avoid invalid attribute on local forms generated by `form_with`George Claghorn2016-12-151-4/+0
| | | | | | | | | | | | | Fixes that the following ERB template would result in invalid HTML output: <%= form_with model: Post.new, local: true do |form| %> <% end %> Specifically, the resulting form tag would have a spurious `remote` attribute: <form remote="false" ...>
* form_with/fields: Don't output ids by defaultKasper Timm Hansen2016-12-131-3/+28
| | | | | | | | | | | Continuing 67f81cc where we decided not to output ids by default in the new form helpers. Went with @dhh's suggestion of just requiring ids on fields being labelled: https://github.com/rails/rails/issues/25197#issuecomment-231797117 Seems okay enough.
* Fix warning: method redefined; discarding old fieldsRyuta Kamizono2016-11-251-1/+1
| | | | Follow up to #26976.
* form_helper typo fix [ci skip]ota42y2016-11-221-1/+1
|
* Add form_with to unify form_tag/form_for. (#26976)Kasper Timm Hansen2016-11-211-2/+341
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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).
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-2/+2
|
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-1/+1
|
* fix document for radio_buttonshingo-nakanishi2016-09-011-1/+2
| | | | add `# Let's say that @user.receive_newsletter returns "no":` for `def radio_button(object_name, method, tag_value, options = {})`. fix `# Let's say that @user.category returns "no":` to `# Let's say that @user.receive_newsletter returns "no":`
* revises more Lint/EndAlignment offensesXavier Noria2016-08-081-9/+9
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-2/+2
|
* applies new string literal convention in actionview/libXavier Noria2016-08-061-13/+13
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Change datetime to datetime-local helper tagHerminio Torres2016-06-211-38/+7
| | | | | | | | | | | A change was made in the helper that renders the `datetime`, being now by default `datetime-local` and creating an alias of `datetime-local` for `datetime`, `datetime` tag and it passes to be an abstract class for all other tags that inherit from him. As a new specification of the HTML 5 the text field type `datetime` will no longer exist and will pass a `datetime-local`. Ref: https://html.spec.whatwg.org/multipage/forms.html#local-date-and-time-state-(type=datetime-local)
* Revert "Merge pull request #17973 from maurogeorge/file_field_hidden_field"eileencodes2016-06-211-18/+0
| | | | | | | | | | | | | The reason we are reverting this commit is because it created breaking changes for file upload gems. For more information see discussion here: https://github.com/rails/rails/issues/17947#issuecomment-225154294 This reverts commit c455817804e4df64c46c17a0cdec0e5a1ca5ba2e, reversing changes made to 8b3cd74b8a09ef85a43d7631bb062a9ec7f57227. Conflicts: actionview/CHANGELOG.md actionview/lib/action_view/helpers/form_helper.rb
* Fix a typo in `time_field` [ci skip]Jake Worth2016-06-051-1/+1
|
* Deprecate `datetime_field` and `datetime_field_tag` helpers.Wojciech Wnętrzak2016-03-311-0/+4
| | | | | Datetime input type was removed from HTML specification. One can use `datetime_local_field` and `datetime_local_field_tag` instead.
* Revert "Merge pull request #22764 from ↵Rafael Mendonça França2016-03-051-2/+0
| | | | | | | | | | stevenspiel/titleize_model_name_for_default_submit_button_value" This reverts commit 4158974c60d817c9bc1e2aecb342161295f2ac0d, reversing changes made to 3d590add45b7ff1de972d99b076cb504d5208935. Reason: This break i18n in some languages. See https://github.com/rails/rails/issues/791#issuecomment-192724640
* html_safe is not supposed to be public API for AV. This change removes usage ↵Vipul A M2016-01-201-2/+2
| | | | | | of html_safe in favour of raw() in AV helpers. Also changed usage of html_safe to make use of raw() instead so that the intended behaviour is verified with raw()
* downcase default submit button value's model nameSteven Spiel2016-01-011-0/+2
|
* [ci skip] Fix which method `FormHelper#date_field` try to callyui-knk2015-09-271-1/+1
| | | | | | | | | | | | When this method was implemented (https://github.com/rails/rails/pull/5016/files), `to_date` is called. But this behavior was chagned refactoring (https://github.com/rails/rails/pull/6452/files). In the first commit, there were not test which asserts `to_date` is called. I think trying `to_date` is more useful than trying `strftime`, because we can write `"2015-01-01".to_date`. But first fix comments to match actual behavior.
* Merge pull request #21431 from ojab/masterRafael Mendonça França2015-09-261-1/+8
|\ | | | | Handle nested fields_for by adding indexes to record_name
| * Handle nested fields_for by adding indexes to record_nameojab2015-08-301-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case of the form with nested fields_for, i. e. <%= form_for :foos, url: root_path do |f| %> <% @foos.each do |foo| %> <%= f.fields_for 'foo[]', foo do |f2| %> <%= f2.text_field :id %> <% foo.bars.each do |bar| %> <%= f2.fields_for 'bar[]', bar do |b| %> <%= b.text_field :id %> <% end %> <% end %> <% end %> <% end %> <%= f.submit %> <% end %> rails doesn't add index for 'foo' in the inner fields_for block, so field names in the outer fields_for looks like "foos[foo][#{foo_index}][id]" and in the inner "foos[foo[]][bar][#{bar_index}][id]". Submitting of such form leads to an error like: >ActionController::BadRequest (Invalid request parameters: expected Array >(got Rack::QueryParser::Params) for param `foo'): This commit adds indexes for the foos in the inner blocks, so field names become "foos[foo][#{foo_index}][bar][#{bar_index}][id]" and submitting of such form works fine as expected. Fixes #15332
* | Correcting output of `file_field` with `multiple` attribute option [ci skip]amitkumarsuroliya2015-09-221-2/+2
| |
* | No need the `a`shingo.nakanishi2015-09-171-2/+2
| |
* | Fixed helpers submit button Examples [ci skip]shingo.nakanishi2015-09-171-1/+1
|/
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-05-081-0/+1
|\
| * [ci skip] Add an example to ActionView::Helpers::FormBuilder#labelyui-knk2015-05-081-0/+1
| |
* | [ci skip] Fix example codes of form_for methodyui-knk2015-05-021-26/+36
| |
* | Override default form builder for a controllerKevin McPhillips2015-04-131-1/+3
|/
* Accept lambda as child_index option in #fields_for methodKarol Galanciak2015-04-051-1/+5
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-03-261-0/+1
|\ | | | | | | | | Conflicts: guides/source/4_0_release_notes.md
| * [ci skip] Add a line between code example and docsyui-knk2015-03-211-0/+1
| |
* | Rework form helper example to use Person.newCarlos Antonio da Silva2015-03-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | The previous change 92a3c8dcdf174dab5e8759031b6bbe6cd891fe3c improved this example, but calling .create + #valid? ends up running validations twice, and we don't want to showcase that. Lets use the normal use case of building a new object and calling #save on it, which is what a basic scaffold with Active Record does. [ci skip]
* | [ci skip] Check a result of `valid?` instead of `create`yui-knk2015-03-211-1/+2
|/
* Fix typos in ActionView::Helpers::FormBuilder comment [ci skip]Yu Haidong2015-02-261-1/+2
|