From abb0c7cb9dd9d0988f8a12960693cfd00857c824 Mon Sep 17 00:00:00 2001 From: ptica Date: Fri, 24 Oct 2014 18:25:31 +0200 Subject: [PATCH 1/2] Update FormHelper.php disabled multiple checkbox input should not generate an enabled hidden input, as it leads to saving empty data upon submission -> carrying the disabled attribute to the hidden input prevents this --- lib/Cake/View/Helper/FormHelper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 815516ba9..66ea22deb 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2069,7 +2069,8 @@ class FormHelper extends AppHelper { 'id' => $attributes['id'] . ($style ? '' : '_'), 'secure' => false, 'form' => isset($attributes['form']) ? $attributes['form'] : null, - 'name' => $attributes['name'] + 'name' => $attributes['name'], + 'disabled' => $attributes['disabled'] ); $select[] = $this->hidden(null, $hiddenAttributes); } From 797635d26b49de2afc24d317944a7820af7c73fd Mon Sep 17 00:00:00 2001 From: Jan Ptacek Date: Sat, 25 Oct 2014 21:05:37 +0200 Subject: [PATCH 2/2] fixing testcases + do not disable the hidden input on partial disables --- lib/Cake/Test/Case/View/Helper/FormHelperTest.php | 4 ++-- lib/Cake/View/Helper/FormHelper.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index d9f69255c..430ae6fc0 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -2695,7 +2695,7 @@ class FormHelperTest extends CakeTestCase { array('label' => array('for' => "ContactMultiple")), 'Multiple', '/label', - array('input' => array('type' => 'hidden', 'name' => "data[Contact][multiple]", 'value' => '', 'id' => "ContactMultiple")), + array('input' => array('type' => 'hidden', 'name' => "data[Contact][multiple]", 'value' => '', 'id' => "ContactMultiple", 'disabled' => 'disabled')), array('div' => array('class' => 'checkbox')), array('input' => array('type' => 'checkbox', 'name' => "data[Contact][multiple][]", 'value' => 1, 'disabled' => 'disabled', 'id' => "ContactMultiple1")), array('label' => array('for' => "ContactMultiple1")), @@ -5004,7 +5004,7 @@ class FormHelperTest extends CakeTestCase { 'Multiple', '/label', 'input' => array( - 'type' => 'hidden', 'name' => 'data[Contact][multiple]', 'value' => '', 'id' => 'ContactMultiple_' + 'type' => 'hidden', 'name' => 'data[Contact][multiple]', 'value' => '', 'id' => 'ContactMultiple_', 'disabled' => 'disabled' ), 'select' => array( 'name' => 'data[Contact][multiple][]', 'disabled' => 'disabled', 'multiple' => 'multiple', 'id' => 'ContactMultiple' diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 66ea22deb..5566a6e9e 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2070,7 +2070,7 @@ class FormHelper extends AppHelper { 'secure' => false, 'form' => isset($attributes['form']) ? $attributes['form'] : null, 'name' => $attributes['name'], - 'disabled' => $attributes['disabled'] + 'disabled' => $attributes['disabled'] === true || $attributes['disabled'] === 'disabled' ); $select[] = $this->hidden(null, $hiddenAttributes); }