mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Improved "required" field detection. Closes #3305.
This commit is contained in:
parent
559130b87b
commit
0ddd130833
2 changed files with 22 additions and 3 deletions
|
@ -119,6 +119,11 @@ class Contact extends CakeTestModel {
|
|||
'between' => array('rule' => array('between', 5, 30), 'allowEmpty' => true),
|
||||
),
|
||||
'imnotrequiredeither' => array('required' => true, 'rule' => array('between', 5, 30), 'allowEmpty' => true),
|
||||
'iamrequiredalways' => array(
|
||||
'email' => array('rule' => 'email'),
|
||||
'rule_on_create' => array('rule' => array('maxLength', 50), 'on' => 'create'),
|
||||
'rule_on_update' => array('rule' => array('between', 1, 50), 'on' => 'update'),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -7068,6 +7073,20 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Contact.iamrequiredalways');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text required'),
|
||||
'label' => array('for' => 'ContactIamrequiredalways'),
|
||||
'Iamrequiredalways',
|
||||
'/label',
|
||||
'input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][iamrequiredalways]',
|
||||
'id' => 'ContactIamrequiredalways'
|
||||
),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -249,11 +249,11 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
foreach ($validationRules as $rule) {
|
||||
$rule->isUpdate($this->requestType === 'put');
|
||||
if ($rule->isEmptyAllowed()) {
|
||||
return false;
|
||||
if (!$rule->isEmptyAllowed()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue