mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
set correct default validate option, now matches saveAll/saveMany default value, fixes #2492
This commit is contained in:
parent
a70c8c7ac3
commit
d4e2fbf6b8
2 changed files with 4 additions and 5 deletions
|
@ -2018,8 +2018,8 @@ class Model extends Object {
|
||||||
*
|
*
|
||||||
* #### Options
|
* #### Options
|
||||||
*
|
*
|
||||||
* - `validate` Set to false to disable validation, true to validate each record before saving,
|
* - `validate` Set to `false` to disable validation, `true` to validate each record before saving,
|
||||||
* 'first' to validate *all* records before any are saved. Defaults to `true`.
|
* 'first' to validate *all* records before any are saved(default),
|
||||||
* - `atomic` If true (default), will attempt to save all records in a single transaction.
|
* - `atomic` If true (default), will attempt to save all records in a single transaction.
|
||||||
* Should be set to false if database/table does not support transactions.
|
* Should be set to false if database/table does not support transactions.
|
||||||
* - `fieldList` Equivalent to the $fieldList parameter in Model::save()
|
* - `fieldList` Equivalent to the $fieldList parameter in Model::save()
|
||||||
|
@ -2036,7 +2036,7 @@ class Model extends Object {
|
||||||
$data = $this->data;
|
$data = $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = array_merge(array('validate' => true, 'atomic' => true), $options);
|
$options = array_merge(array('validate' => 'first', 'atomic' => true), $options);
|
||||||
$this->validationErrors = $validationErrors = array();
|
$this->validationErrors = $validationErrors = array();
|
||||||
|
|
||||||
if (empty($data) && $options['validate'] !== false) {
|
if (empty($data) && $options['validate'] !== false) {
|
||||||
|
|
|
@ -4260,8 +4260,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'user_id' => 1
|
'user_id' => 1
|
||||||
),
|
),
|
||||||
'Attachment' => array('attachment' => '')
|
'Attachment' => array('attachment' => '')
|
||||||
),
|
)
|
||||||
array('validate' => 'first')
|
|
||||||
), false);
|
), false);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Comment' => array('comment' => array('This field cannot be left blank')),
|
'Comment' => array('comment' => array('This field cannot be left blank')),
|
||||||
|
|
Loading…
Reference in a new issue