Hello,
I'm actually working on a new project with CI4.
It's greats :-)
But I have some problems wit ajax request and validation.
My view :My Controller :
What's wrong ?
I'm actually working on a new project with CI4.
It's greats :-)
But I have some problems wit ajax request and validation.
My view :
Code:
axios.post({
method: 'post',
url: '/my_url',
data: {
email: '[email protected]',
id: 12
}
})
PHP Code:
$this->validation->setRules([
'email' => ['label' => 'Email', 'rules' => 'required|valid_email',],
'id' => ['label' => 'Lien URL', 'rules' => 'required|integer',],
];
if (! $this->validation->withRequest($this->request)->run()) {
return $this->response->setStatusCode(400, $this->validation->listErrors());
}
return $this->response->setJSON([
'success' => true,
]);
What's wrong ?