Symfony2 - fos create custom super admin field

I am launching the SF2.1 project into production.
I have customized the user model so that some fields are needed.
So when I try to create my super admin

$ php app/console fos:user:create admin my@mail.com my_pass --super-admin 

I get

[PDOException]
SQLSTATE [23000]: Integrity constraint violation: 1048 Column 'my_required_field' cannot be null

What is the clean way to manage this?
I assume that manually do not insert the user into the table ...

+4
source share
2 answers

You must override the FOSUserBundle execute() method in /Command/CreateUserCommand.php and the create() method in /Util/UserManipulator.php . By doing so, you can add any additional fields to the user object from the command line.

+6
source

You can either override the CLI command to provide the required field, or simply provide the default value in the class constructor if it is a scalar.

+3
source

All Articles