Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit ad51115e12d5685483c0d794191878ab145d8631 1 parent 9b040a5
@lorenzo lorenzo authored
View
2  cake/libs/view/helpers/form.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);
}
View
12 cake/tests/cases/libs/view/helpers/form.test.php
@@ -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'
);
Please sign in to comment.
Something went wrong with that request. Please try again.