This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Symfony wants to create null object in database

Discussion relating to version 1.3.x and 1.4.x

Symfony wants to create null object in database

by latata » Mon Sep 08, 2014 9:28 am

I work on symfony 1.4 (doctrine) project. I've added relation to my sfGuardUserProfile model:

Code: Select all
          tableName: sf_guard_user_profile
            id:                     { type: integer(20), primary: true, autoincrement: true }
            user_id:                { type: integer(20), notnull: true }
            username:               { type: string(128), notnull: false }
    city:                   { type: string(255) }
              class: sfGuardUser
              foreign: id
              local: user_id
              type: one
              onDelete: cascade
              foreignType: one
              foreignAlias: Profile
              class:          City
              local:          city
              foreign:        woeid
              onDelete:       cascade
              type:           one

Now, when I try to save sfGuardUserProfile object (city value is null) it tries to create new record in cities table with all fields null and I get an sql exception `Column country_id cannot be null`. country_id is a field in city table (and model). How to prevent inserting this null city object?

Screenshot of exception:
Junior Member
Posts: 1
Joined: Mon Sep 08, 2014 9:26 am