Skip to content

Instantly share code, notes, and snippets.

Created September 29, 2014 02:19
Show Gist options
  • Save anonymous/96d9acfec99f2c09da10 to your computer and use it in GitHub Desktop.
Save anonymous/96d9acfec99f2c09da10 to your computer and use it in GitHub Desktop.
One to One Relationship embed form
Im getting this error:
Notice: Undefined index: userId in /var/www/html/symfony2/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 688
class UsersType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('username')
->add('password')
->add('user', new UserFieldsType())
;
}
Acme\DemoBundle\Entity\Users:
type: entity
table: users
uniqueConstraints:
user_id_UNIQUE:
columns:
- user_id
id:
user_id:
type: integer
generator:
strategy: AUTO
fields:
username:
type: text
nullable: true
length: null
fixed: false
comment: ''
password:
type: text
nullable: true
length: null
fixed: false
comment: ''
oneToOne:
user:
targetEntity: UserFields
cascade:
- all
mappedBy: null
inversedBy: null
joinColumns:
user_id:
referencedColumnName: user_id
orphanRemoval: false
lifecycleCallbacks: { }
Acme\DemoBundle\Entity\UserFields:
type: entity
table: user_fields
uniqueConstraints:
user_id_UNIQUE:
columns:
- user_id
id:
id:
type: integer
nullable: false
unsigned: false
comment: ''
id: true
generator:
strategy: IDENTITY
fields:
userId:
type: integer
nullable: true
unsigned: false
comment: ''
column: user_id
age:
type: text
nullable: true
length: null
fixed: false
comment: ''
lifecycleCallbacks: { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment