2010-08-02 129 views
0

我有以下架構定義:如何保存多對多關係中的相關對象?

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」,我已經試過symfony的文檔中的高級形式的章節,但我不想嵌入表單,我想單獨使用它作爲另一個表單。

謝謝。

回答

1

如果您在最近的版本中使用Doctrine(我不知道,因爲當它存在時),當關聯對象被保存時,您的關係將被保存,假設關係已經改變。這項工作沒有嵌入式表單(即使沒有表單),它是一個不同的事情,也是ORM的一部分。

如果此行爲不起作用,那麼您的模型聲明在schema.yml中存在問題

+0

謝謝我會檢查它 – JaSk 2010-08-06 17:21:48