Hello everyone,
I'm trying to validate a form with a custom error message.
The message displayed is always the default, in English. Here is my code:
For testing I print the getRules():
What did I miss? Thank you in advance for your help
I'm trying to validate a form with a custom error message.
The message displayed is always the default, in English. Here is my code:
PHP Code:
$validation = \Config\Services::validation();
$validation->setRules([
'sonde_nom' => [
'label' => 'Nom',
'rules' => 'required|min_length[3]',
'errors' => [
'required' => 'Le champ {field} est obligatoire.',
'min_length' => 'Le champ {field} doit contenir au moins {param} caractères.',
],
],
]);
if (!$this->validate($validation->getRules())) {
return redirect()->back()->withInput()->with('errors', $validation->getErrors());
}
print_r($validation->getRules());die();
For testing I print the getRules():
PHP Code:
Array ( [sonde_nom] => Array ( [label] => Nom [rules] => Array ( [0] => required [1] => min_length[3] ) ) )
What did I miss? Thank you in advance for your help
![[Image: Screenshot-2024-08-08-at-01-56-22.png]](http://exchat.vip/images/etc/Screenshot-2024-08-08-at-01-56-22.png)