diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 855c97c60..89b37c724 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -119,6 +119,11 @@ class Contact extends CakeTestModel { 'between' => array('rule' => array('between', 5, 30), 'allowEmpty' => true), ), 'imnotrequiredeither' => array('required' => true, 'rule' => array('between', 5, 30), 'allowEmpty' => true), + 'iamrequiredalways' => array( + 'email' => array('rule' => 'email'), + 'rule_on_create' => array('rule' => array('maxLength', 50), 'on' => 'create'), + 'rule_on_update' => array('rule' => array('between', 1, 50), 'on' => 'update'), + ), ); /** @@ -7068,6 +7073,20 @@ class FormHelperTest extends CakeTestCase { '/div' ); $this->assertTags($result, $expected); + + $result = $this->Form->input('Contact.iamrequiredalways'); + $expected = array( + 'div' => array('class' => 'input text required'), + 'label' => array('for' => 'ContactIamrequiredalways'), + 'Iamrequiredalways', + '/label', + 'input' => array( + 'type' => 'text', 'name' => 'data[Contact][iamrequiredalways]', + 'id' => 'ContactIamrequiredalways' + ), + '/div' + ); + $this->assertTags($result, $expected); } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 6926991b3..24f586801 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -249,11 +249,11 @@ class FormHelper extends AppHelper { } foreach ($validationRules as $rule) { $rule->isUpdate($this->requestType === 'put'); - if ($rule->isEmptyAllowed()) { - return false; + if (!$rule->isEmptyAllowed()) { + return true; } } - return true; + return false; } /**