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)) { if (is_array($validateProperties)) {
$dims = Set::countDim($validateProperties); $dims = Set::countDim($validateProperties);
if ($dims == 1) { if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) {
$validateProperties = array($validateProperties); $validateProperties = array($validateProperties);
} }

View file

@ -114,7 +114,7 @@ class Contact extends CakeTestModel {
'between' => array('rule' => array('between', 5, 30)), 'between' => array('rule' => array('between', 5, 30)),
), ),
'imnotrequiredeither' => array('required' => true, 'rule' => array('between', 5, 30), 'allowEmpty' => true), 'imnotrequiredeither' => array('required' => true, 'rule' => array('between', 5, 30), 'allowEmpty' => true),
); );
/** /**
* schema method * schema method
@ -5597,15 +5597,15 @@ class FormHelperTest extends CakeTestCase {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Form->input('Contact.iamnotrequiredeither'); $result = $this->Form->input('Contact.imnotrequiredeither');
$expected = array( $expected = array(
'div' => array('class' => 'input text'), 'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactIamnotrequiredeither'), 'label' => array('for' => 'ContactImnotrequiredeither'),
'Iamnotrequiredeither', 'Imnotrequiredeither',
'/label', '/label',
'input' => array( 'input' => array(
'type' => 'text', 'name' => 'data[Contact][iamnotrequiredeither]', 'type' => 'text', 'name' => 'data[Contact][imnotrequiredeither]',
'id' => 'ContactIamnotrequiredeither' 'id' => 'ContactImnotrequiredeither'
), ),
'/div' '/div'
); );