Registration form - custom User fields triggering 'required' validation error #464
-
I'm new to CI4 & to Myth/Auth. I've tried to follow these instructions for adding three custom User fields (first_name, last_name, mobile_phone) to the user registration function: https://github.com/lonnieezell/myth-auth/blob/develop/docs/extending.md I'm having trouble with the validation of these custom fields. When I submit the form with the three new fields completed, the 'field is required' validation message is displayed for all three of these fields (e.g. "First Name is required"). It's as if the $_POST variables from the View are not available to the Model. I've spent a day on this, but I can't work out what is going on. Any ideas on what I need to check for? Here's my code... My version of AuthController with the attemptRegister method so that I could change the email and password validation messages:
Snippet from my version of the View register.php, showing the three new fields:
My version of UserModel, with the three new fields in $allowedFIelds and $validationRules:
My version of the User entity, with a getName method:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
OK, I solved this. I had to add the three new fields to the $validFields array in app/Config/Auth.php. This step wasn't mentioned in https://github.com/lonnieezell/myth-auth/blob/develop/docs/extending.md
|
Beta Was this translation helpful? Give feedback.
OK, I solved this.
I had to add the three new fields to the $validFields array in app/Config/Auth.php. This step wasn't mentioned in https://github.com/lonnieezell/myth-auth/blob/develop/docs/extending.md