I want to register user and I have 3 fields in form; login, password and confirm_password. In database I have column login
, password
and role
. So I want to insert database user which have default role User
. This oode below show me error SQLSTATE[HY000]: General error: 1364 Field 'role' doesn't have a default value
. How can I resolve this problem ?
3
Answers
You need to add/modify the Role column with your SQL Client, chances are you have not defined a default value to it, and the column is a "Not Null" one meaning you can’t insert a row if this column is empty.
Another option is to have something like that with your create function :
If you create users only with role "User" you can add this line when you create user;
Or you can use Observer:
Controller Logic:
Model Logic if you want to insert default value