Welcome Guest, Not a member yet? Register   Sign In
Input validation return empty array
#1

I'm facing a weird issue trying to validate post input.
Following the userguide I set a controller to validate few POST input sent using a form.
The controller is the following:
Code:
public function collection()
{

    if ( $this->request->is('post')) {
        $rules = [
            'record'    => 'alpha_numeric_punct',
            'record_id' => 'is_natural_no_zero',
            'region'    => 'is_natural_no_zero',
        ];

        $data = $this->request->getPost(array_keys($rules));

        if (! $this->validateData($data, $rules)) {
            $errors = $this->validator->getErrors();
        }
       
        $validData = $this->validator->getValidated();

        $data['validated'] = $validData;
        $data['errors'] = $errors;
    }
}

In my view, using a print_r command, I get and empty array as 'validated' data...while 'errors' return the error if input are not valid. I really cannot understand what's wrong with $validData and why I get an empty array. Anny hint or help to figure out what's wrong?
Thanks a lot for any help.
Reply


Messages In This Thread
Input validation return empty array - by Vespa - 11-02-2024, 02:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB