Form Validation Allowing Empty Strings To Be Stored Instead of Null |
I'm trying to get form validation to work at the model level. I have three fields, id, name and email, and I have them all set to required.
I'm using the CI 4 Entity class, so on an incoming request, I get the JSON, fill my new Entity on creation, and then pass to the model. No matter what I do, for the fields name and email (set to varchar 150 and not NULL in SQL), when I try to insert, name and email are stored as empty strings when I don't include them in my JSON (for instance, if I pass id alone). How can I make it so that if the name and email keys are not passed, the required error is shown? Model: PHP Code: <?php Controller: PHP Code: public function create() |
Messages In This Thread |
Form Validation Allowing Empty Strings To Be Stored Instead of Null - by viewfromthenorth - 10-07-2019, 07:34 PM
RE: Form Validation Allowing Empty Strings To Be Stored Instead of Null - by kilishan - 10-07-2019, 07:53 PM
RE: Form Validation Allowing Empty Strings To Be Stored Instead of Null - by viewfromthenorth - 10-07-2019, 08:00 PM
|