Symfony1 如何在多对多关系中保存相关对象?
我有以下模式定义:Symfony1 如何在多对多关系中保存相关对象?,symfony1,doctrine,symfony-1.4,Symfony1,Doctrine,Symfony 1.4,我有以下模式定义: Usuario: columns: empresa_id: { type: BIGINT, notnull: true } direccion_id: { type: BIGINT, notnull: false } publicidad_id: { type: BIGINT, notnull: true } tipo_id: { type: BIGINT, notnull: true } nombre: {
Usuario:
columns:
empresa_id: { type: BIGINT, notnull: true }
direccion_id: { type: BIGINT, notnull: false }
publicidad_id: { type: BIGINT, notnull: true }
tipo_id: { type: BIGINT, notnull: true }
nombre: { type: string(60), notnull: true }
paterno: { type: string(60), notnull: true }
materno: { type: string(60), notnull: true }
curp: { type: string(20), notnull: false }
rfc: { type: string(13), notnull: false }
correoPrincipal: { type: string(100), notnull: true, unique: true }
correoSecundario: { type: string(100), notnull: false, unique: true }
telefonoFijo: { type: string(12), notnull: true }
telefonoMovil: { type: string(12), notnull: false }
validado: { type: boolean, notnull: false, default: false }
usuario: { type: string(10), notnull: false }
password: { type: string(10), notnull: false }
matricula: { type: string(16), notnull: false }
fechaNacimiento: { type: date, notnull: true }
relations:
Direccion: { onDelete: CASCADE, local: direccion_id, foreign: id }
Empresa: { onDelete: CASCADE, local: empresa_id, foreign: id, class: Empresa }
Publicidad: { onDelete: CASCADE, local: publicidad_id, foreign: id }
Tipo: { onDelete: CASCADE, local: tipo_id, foreign: id, class: conamatTipo }
Bachillerato:
class: Bachillerato
refClass: BachilleratoUsuario
local: usuario_id
foreign: bachillerato_id
foreignAlias: Usuarios
UsuarioSede:
class: Sede
refClass: SedeUsuario
local: usuario_id
foreign: sede_id
foreignAlias: Usuario
SedeUsuario:
columns:
sede_id: { type: bigint, notnull: true }
usuario_id: { type: bigint, notnull: true }
relations:
Usuario: { local: usuario_id, foreign: id }
Sede: { local: sede_id, foreign: id }
如何制作一个表单,让我在一个“usuario”中添加多个“sede”,我已经尝试了symfony文档中的高级表单章节,但我不想嵌入表单,我想单独将其用作另一个表单
谢谢。如果您在最新版本中使用了条令(我不知道这是什么时候出现的),则在保存相关对象时,您的关系将被保存,前提是关系已更改。这项工作没有嵌入表单(即使没有表单),它是另一回事,是ORM的一部分 如果此行为不起作用,则是schema.yml中的模型声明有问题