diff options
author | Rafael França <rafael@franca.dev> | 2019-07-26 13:48:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-26 13:48:18 -0400 |
commit | 1760fe919f51cfdcb375847e1ed4a9c0f4827720 (patch) | |
tree | a5544acbcf65713fd8cc25fa553425b903168e40 | |
parent | f45e23ead96507c2bb582c223f2615ca71244312 (diff) | |
parent | 64631d83c561510579a04ac8317ab644e52ab714 (diff) | |
download | rails-1760fe919f51cfdcb375847e1ed4a9c0f4827720.tar.gz rails-1760fe919f51cfdcb375847e1ed4a9c0f4827720.tar.bz2 rails-1760fe919f51cfdcb375847e1ed4a9c0f4827720.zip |
Merge pull request #36764 from willianveiga/feature/inputs-inside-disabled-fieldset-are-not-submited-on-remote-true-forms
Inputs inside disabled fieldset are not submited on remote: true forms
-rw-r--r-- | actionview/app/assets/javascripts/rails-ujs/utils/form.coffee | 1 | ||||
-rw-r--r-- | actionview/test/ujs/public/test/data-remote.js | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/actionview/app/assets/javascripts/rails-ujs/utils/form.coffee b/actionview/app/assets/javascripts/rails-ujs/utils/form.coffee index 736cab08db..9e11bfa7ed 100644 --- a/actionview/app/assets/javascripts/rails-ujs/utils/form.coffee +++ b/actionview/app/assets/javascripts/rails-ujs/utils/form.coffee @@ -11,6 +11,7 @@ Rails.serializeElement = (element, additionalParam) -> inputs.forEach (input) -> return if !input.name || input.disabled + return if input.closest('fieldset[disabled]') if matches(input, 'select') toArray(input.options).forEach (option) -> params.push(name: input.name, value: option.value) if option.selected diff --git a/actionview/test/ujs/public/test/data-remote.js b/actionview/test/ujs/public/test/data-remote.js index 16ea114f3b..dbbb383995 100644 --- a/actionview/test/ujs/public/test/data-remote.js +++ b/actionview/test/ujs/public/test/data-remote.js @@ -490,4 +490,22 @@ asyncTest('changing a select option without "data-url" attribute still fires aja setTimeout(function() { start() }, 20) }) +asyncTest('inputs inside disabled fieldset are not submited on remote forms', 3, function() { + $('form') + .append('<fieldset>\ + <input name="description" value="A wise man" />\ + </fieldset>') + .append('<fieldset disabled="disabled">\ + <input name="age" />\ + </fieldset>') + .bindNative('ajax:success', function(e, data, status, xhr) { + equal(data.params.user_name, 'john') + equal(data.params.description, 'A wise man') + equal(data.params.age, undefined) + + start() + }) + .triggerNative('submit') +}) + })() |