a falta de validar

This commit is contained in:
Jaime Jiménez
2023-07-13 08:22:09 +02:00
parent c4a7cfc799
commit ade327004f
4 changed files with 71 additions and 8 deletions

View File

@ -75,15 +75,23 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
// JJO
$sanitizedData['user_created_id'] = $session->id_user;
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
// JJO: se añade que se checkeen los intervalos de ancho y tirada.
// En caso de error se devuelve un mensaje.
try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
$error = $this->model->checkIntervals($sanitizedData);
if(empty($error)){
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
}
else{
$successfulResult = false;
$this->viewData['errorMessage'] = $error;
$this->session->setFlashdata('formErrors', $this->model->errors());
}
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
@ -160,12 +168,20 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
// JJO: se añade que se checkeen los intervalos de ancho y tirada.
// En caso de error se devuelve un mensaje.
try {
$error = $this->model->checkIntervals($sanitizedData);
if(empty($error)){
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
}
else{
$successfulResult = false;
$this->viewData['errorMessage'] = $error;
$this->session->setFlashdata('formErrors', $this->model->errors());
}
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);