Romain
Romain

Reputation: 3673

How to validate a POST request for postUserAction

I get a problem with the validation of a new user request on my api. I know there's a problem in my code but I cannot figure it out :

UserType

postUserAction

And I send via google Postman, this json :

{
  "username":"Username",
  "email":"[email protected]",
  "plainPassword":"SecretPassword",
  "lastname":"Smith",
  "firstname":"John",
  "job_position":"CEO",
  "phone":"+666133742",
  "company_name":"Microtosh",
  "website":"www.omgthatsaflippingspider.com",
  "sector":"Food & Stuff",
  "address":"12 st Overkill",
  "city":"SinCity",
  "zip_code":"W4224",
  "country":"US",
  "billing_infos_same_as_company":true,
  "putf":"1",
  "das":"Manchester United"
}

Now I seems to validate but I get an error :

Column 'password' cannot be null

When I look up the $form -- before $userManager->updateUser($user) -- I get this :

plainPassword:
{
    -children:
    {
        -first:
        {
            -errors:
            [
                "fos_user.password.mismatch"
            ]
        }
        second: [ ]
    }
}

Now first, why does it validate since it didn't find a match between password and confirmation ?

And am I doing the right thing, with the creation of a new user ? I don't understand what I am missing.

Upvotes: 0

Views: 108

Answers (1)

Jovan Perovic
Jovan Perovic

Reputation: 20201

Just change the form type of password field to password instead of repeated and it should work ;)

Upvotes: 1

Related Questions