I am trying to create a user manually. however I am getting following error. Basically it returns post values as null
An exception occurred while executing 'INSERT INTO users (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at, name, surname, company) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [null, null, null, null, 1, "48vgaw6nv7y8kk48kwo4k8o4os44c4c", null, null, 0, 0, null, null, null, "a:0:{}", 0, null, null, null, null]:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'username' cannot be null
here is my code
/**
* @Route("/add-user", name="add-user")
*/
public function AddUserAction(request $request)
{
$userManager = $this->container->get('fos_user.user_manager');
$name=$request->request->get("name");
$surname=$request->request->get("surname");
$comapany=$request->request->get("company");
$username=$request->request->get("username");
$password=$request->request->get("password");
$email=$request->request->get("email");
$tel=$request->request->get("tel");
$mobile=$request->request->get("mobile");
$role=$request->request->get("role");
$user = $userManager->createUser();
$user->setUsername($username);
$user->setEmail($email);
$user->setPlainPassword($password);
$user->setRoles(array($role));
$user->setEnabled(true);
$userManager->updateUser($user);
return $this->redirect($this->generateUrl('index'));
}