Database error, not null violation, I am passing all values, where am I going wrong?

0

After completing the form and submitting, returns the following array :

array(
       'User' => array(
               'password' => '*****',
               'nome' => 'Engenharia',
               'username' => '[email protected]',
               'confirm_password' => '123',
       ),
       'Endereco' => array(
               (int) 0 => array(
                    'cidade_id' => '3091',
                          'cep' => '96032012',
                          'rua' => 'Conde de porto alegre',
                          'numero' => '420',
                          'bairro' => 'Porto',
                          'complemento' => 'Empresa'
                  )
        ),
        'UserGroup' => array(
                 'group_id' => '2',
                 'nome' => 'Cliente'
         )
)

Then I get the following message:

  

Database Error   Error: SQLSTATE [23502]: Not null violation: 7 ERROR: null value in column "name" violates not-null constraint. DETAIL: Failing row contains (87, 2, 180, null)
  Notice: If you want to customize this error message, create app / View / Errors / pdo_error.ctp

But I do not understand where it's taking this nome == null , because I'm passing the name of User and I'm passing the name of UserGroup also, where can I be wrong?

    
asked by anonymous 26.12.2016 / 19:10

1 answer

0

My solution:

After completing the form and submitting, returns the following array :

array(
       'User' => array(
               'password' => '*****',
               'nome' => 'Engenharia',
               'username' => '[email protected]',
               'confirm_password' => '123',
       ),
       'Endereco' => array(
               (int) 0 => array(
                    'cidade_id' => '3091',
                          'cep' => '96032012',
                          'rua' => 'Conde de porto alegre',
                          'numero' => '420',
                          'bairro' => 'Porto',
                          'complemento' => 'Empresa'
                  )
        ),
        'UserGroup' => array(
                 'group_id' => '2',
         )
)
  

I removed the nome field from the conflicting table UserGroup and used the nome (I needed) from another table already in the database, so I only made a relationship in Controller to call this table and it worked perfectly !!

    
27.12.2016 / 11:54