Good morning guys, I have the following problem and I would like some help:
In the controller, I perform a double validation, occupying 2 specific fields of the views, it works fine, that is, if the condition is true, it returns an error message, and then I perform a redirect. What’s going on? that the redirect is for the add and it works fine, but when performing the redirect, the form remains empty.
Is there a way to perform the redirect but without the empty fields? Or do you recommend that I do it in another way?
I share code snippet to visualize better.
if ($this->request->is('post')) {
$delivery = $this->Deliveries->patchEntity($delivery, $this->request->getData());
$users = $delivery->users_id;
$usersC = $this->Deliveries->users->find()
->select(['id'])
->where(['id' => $users]);
$usersd = $usersC->first();
if(!$usersd && $delivery->delivered == 0){
$this->Flash->error("error message");
return $this->redirect(['controller' => 'Deliveries', 'action' => 'add']);
}
}
Thanks for your help