mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
9b040a5ed3
commit
ad51115e12
2 changed files with 7 additions and 7 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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'
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue