Permalink
Browse files

Fixing bug where required class would be added to form fields when us…

…ing single rule syntax in $validate even if allowEmpty is set to true


Closes #654
  • Loading branch information...
lorenzo committed Apr 30, 2010
1 parent 9b040a5 commit ad51115e12d5685483c0d794191878ab145d8631
Showing with 7 additions and 7 deletions.
  1. +1 −1 cake/libs/view/helpers/form.php
  2. +6 −6 cake/tests/cases/libs/view/helpers/form.test.php
@@ -148,7 +148,7 @@ function _isRequiredField($validateProperties) {
if (is_array($validateProperties)) {
$dims = Set::countDim($validateProperties);
- if ($dims == 1) {
+ if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) {
$validateProperties = array($validateProperties);
}
@@ -114,7 +114,7 @@ class Contact extends CakeTestModel {
'between' => array('rule' => array('between', 5, 30)),
),
'imnotrequiredeither' => array('required' => true, 'rule' => array('between', 5, 30), 'allowEmpty' => true),
- );
+ );
/**
* schema method
@@ -5597,15 +5597,15 @@ function testFormMagicInput() {
);
$this->assertTags($result, $expected);
- $result = $this->Form->input('Contact.iamnotrequiredeither');
+ $result = $this->Form->input('Contact.imnotrequiredeither');
$expected = array(
'div' => array('class' => 'input text'),
- 'label' => array('for' => 'ContactIamnotrequiredeither'),
- 'Iamnotrequiredeither',
+ 'label' => array('for' => 'ContactImnotrequiredeither'),
+ 'Imnotrequiredeither',
'/label',
'input' => array(
- 'type' => 'text', 'name' => 'data[Contact][iamnotrequiredeither]',
- 'id' => 'ContactIamnotrequiredeither'
+ 'type' => 'text', 'name' => 'data[Contact][imnotrequiredeither]',
+ 'id' => 'ContactImnotrequiredeither'
),
'/div'
);

0 comments on commit ad51115

Please sign in to comment.