Symfony1 动态嵌入表单

Symfony1 动态嵌入表单,symfony1,symfony-1.4,Symfony1,Symfony 1.4,我正在尝试使用模式中的单个表动态添加嵌入表单 我的意思是,在我的sfGuardUserProfile表中,我有许多字段来确定用户是什么,即执业id、护士id、患者id 因此,考虑到这一点,我试图动态地将护士添加到实践中 我有一个练习表,它扩展了sfGuardUserAdminForm,它扩展了sfGuardUser,这样我就可以获得存储在sfGuardUser表中的用户名、密码等 在我的practiceForm中,我嵌入了一个practiceProfileform,它显示了我从sfGuardUs

我正在尝试使用模式中的单个表动态添加嵌入表单

我的意思是,在我的
sfGuardUserProfile
表中,我有许多字段来确定用户是什么,即执业id、护士id、患者id

因此,考虑到这一点,我试图动态地将护士添加到实践中

我有一个练习表,它扩展了
sfGuardUserAdminForm
,它扩展了
sfGuardUser
,这样我就可以获得存储在
sfGuardUser
表中的用户名、密码等

在我的
practiceForm
中,我嵌入了一个
practiceProfileform
,它显示了我从
sfGuardUserProfile
表中需要的字段。我希望每个人都在关注

这很好,我看到了两个表中的字段

现在,我有点不确定该怎么做:把护士们安插进去。我特别不确定如何做到这一点,因为实践和护士将保存在同一张表中

实习形式

class Practiceform extends sfGuardUserAdminForm 
{
    public function configure()
    {
       $form = new PracticeProfileForm($this->getObject()->getProfile());
       $this->embedForm('profile', $form);
    }
}
我还有一个nurseForm,它再次扩展了
sfGuardUser
,嵌入了一个nurseProfileForm,它扩展了
sfGuardUserProfile
,以获取我需要的字段

托儿所

class dentistForm extends sfGuardUserAdminForm 
{
    public function configure()
    {
       $profileForm = new nurseProfileForm($this->object->Profile);
       $this->embedForm('profile', $profileForm);

{
}

我的schema.yml如下所示:

sfGuardUserProfile:
  actAs:
    Timestampable: ~
  columns:
    user_id:
      type: integer(11)
      notnull: true
      default:
      unsigned: false
      primary: false
      unique: false
      autoincrement: false
    email_new:
      type: string(255)
      unique: true
    firstname:
      type: string(255)
    lastname:
      type: string(255)
    practice_id:
      type: integer(11)
    nurse_name:
      type: varchar(255)
    practice_name:
      type: varchar(255)
    practice_type:
      type: varchar(255)
    validate_at:
      type: timestamp
    validate:
      type: string(33)
  relations:
    User:
      class: sfGuardUser
      foreign: id
      local: user_id
      type: one
      onDelete: cascade
      foreignType: one
      foreignAlias: Profile
   Practice:
      class: sfGuardUserProfile
      foreign: id
      local: practice_id
      type: one
      onDelete: cascade
  indexes:
    validate:
      fields: [validate]
有没有一种简单的方法可以实现使用Doctrine/SF1.4动态添加这些护士


谢谢

我强烈建议您首先重新考虑您的模式。您真的需要将所有实体存储在一个表中吗

相反,使用不同的实体(类)及其与sfGuardUser相关的特定字段。例如:

Nurse:
  columns:
    account_id: integer(4)
    name: string(255)
    ...
  relations:
    Account:
      class: sfGuardUser
      local: account_id
      foreign: id
      type: one
      foreignType: one
然后,您可以将护士关系嵌入到SFGuardPerform中:

class sfGuardUserForm
{
    public function configure()
    {
       $this->embedRelation('Nurse');
    }
}
或者,反过来说:

class NurseForm
{
    public function configure()
    {
       $this->embedRelation('Account');
    }
}
并对所有其他实体执行相同的操作。然而,如果你觉得你的性情几乎相同,你可以看看教义的传承,尽管它通常是不受欢迎的