Skip to content

Commit

Permalink
Fixing bug where required class would be added to form fields when us…
Browse files Browse the repository at this point in the history
…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 ad51115
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/form.php
Expand Up @@ -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);
}

Expand Down
12 changes: 6 additions & 6 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -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
Expand Down Expand Up @@ -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'
);
Expand Down

0 comments on commit ad51115

Please sign in to comment.