Fixing bug where required class would be added to form fields when using single rule syntax in $validate even if allowEmpty is set to true

Closes #654
This commit is contained in:
José Lorenzo Rodríguez 2010-04-30 16:42:59 -04:30
parent 9b040a5ed3
commit ad51115e12
2 changed files with 7 additions and 7 deletions

View file

@ -148,7 +148,7 @@ class FormHelper extends AppHelper {
if (is_array($validateProperties)) {
$dims = Set::countDim($validateProperties);
if ($dims == 1) {
if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) {
$validateProperties = array($validateProperties);
}

View file

@ -5597,15 +5597,15 @@ class FormHelperTest extends CakeTestCase {
);
$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'
);