mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +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)) {
|
||||
|
||||
$dims = Set::countDim($validateProperties);
|
||||
if ($dims == 1) {
|
||||
if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) {
|
||||
$validateProperties = array($validateProperties);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ 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'
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue