0

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":"example@mail.com",
  "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.

Romain
  • 3,586
  • 7
  • 31
  • 52
  • 1
    It's unclear a bit. Did you in fact comment out `plainPassword` form field? And why would you set the form type to `repeated` if you are building an API? – Jovan Perovic Sep 02 '14 at 14:58
  • Well no I commented it for a test, sorry about that. And now that you mention it, I don't know why I put 'repeated' as I looked everywhere to assemble my code, trying to do the right one. I'll try to put it without the repeated. – Romain Sep 02 '14 at 15:05
  • Yup, tested it aaaaaand it work perfectly. Please make it an answer so I can validate the hell out of it. I love you. – Romain Sep 02 '14 at 15:09

1 Answers1

1

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

Jovan Perovic
  • 19,846
  • 5
  • 44
  • 85