From 2dbe64dc1570aa713a5e2fd8a18109a3190e619f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 24 Sep 2015 20:33:31 +0200 Subject: [PATCH] Improved trim with multiple form fields. --- .../controllers/_application_controller_form.js.coffee | 2 +- app/views/tests/form_trim.html.erb | 6 ++++++ public/assets/tests/form-trim.js | 9 +++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index aca9cee32..4d62d72be 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -452,7 +452,7 @@ class App.ControllerForm extends App.Controller if typeof param[key.name] is 'string' param[key.name] = [param[key.name], key.value.trim()] else - param[key.name].push key.value + param[key.name].push key.value.trim() else param[key.name] = key.value.trim() diff --git a/app/views/tests/form_trim.html.erb b/app/views/tests/form_trim.html.erb index e81d806f0..219ed5dc8 100644 --- a/app/views/tests/form_trim.html.erb +++ b/app/views/tests/form_trim.html.erb @@ -22,6 +22,12 @@ body { + + + + + + diff --git a/public/assets/tests/form-trim.js b/public/assets/tests/form-trim.js index 9a8e73d76..d2ee3875e 100644 --- a/public/assets/tests/form-trim.js +++ b/public/assets/tests/form-trim.js @@ -8,6 +8,12 @@ test( 'form trim checks', function() { input3: 'a', input4: 'a b', input5: 'äö ü', + input6: [ + 'a', + 'b', + 'c', + 'd' + ], textarea1: '', textarea2: '', textarea3: 'a', @@ -23,6 +29,5 @@ test( 'form trim checks', function() { var params = App.ControllerForm.params( el ) deepEqual( params, test_params, 'form param check' ) - console.log('22', params) - console.log('22', test_params) + })