Form Validation in Model Table
Validating entities before saving is done automatically when using the newEntity(), newEntities(), patchEntity() or patchEntities()
Go to database access validation doc
use validating data before building entities
use users model
First create a users database table
error() function has been deprecated, use the getErrors() function instead
now create model table for validation
Create Users Table file in `src/Model/Table` folder
modify demo code
insert php namespace (App\Model\Table)
show form validation errors
Update registration file
Now send errors and data to registration template
And this variable name can be used in the template
Now you will see the error below the same field in which error occurs
Now set the error template
Modify the template according to the css of the form in Bootstrap 4
You can show the validation error in another way
Use this function to check the error of a unique field
This function sends us the boolean value
use if condition in html controls
Now we are getting the form validation error right
Now let's use the condition in all the controls like this
Không có nhận xét nào:
Đăng nhận xét