后端 sfGuardUser 模块 [英] Backend sfGuardUser module

查看:33
本文介绍了后端 sfGuardUser 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 symfony 1.4.11 和 Doctrine

I use symfony 1.4.11 with Doctrine

我在后端有 sfGuardUser 模块.我有 sfGuardUserProfile 表.

I have sfGuardUser module in backend. I have sfGuardUserProfile table.

sfGuardUserProfile:
  connection: doctrine
  tableName: sf_guard_user_profile
  columns:
    id:            { type: integer(4), primary: true, autoincrement: true }
    user_id:       { type: integer(4), notnull: true }
    salutation:    { type: string(10), notnull: true }
    first_name:    { type: string(30), notnull: true }
    last_name:     { type: string(30), notnull: true }
    country:       { type: string(255), notnull: true }
    postcode:      { type: string(10) , notnull: true }
    city:          { type: string(255), notnull: true }
    address:       { type: string()   , notnull: true }
    phone:         { type: string(50) }
    email:         { type: string(255), notnull: true }
    validate:      { type: string(17) }
    banned:        { type: boolean, default: 0 }
    payed_until:   { type: datetime, notnull: true}
  relations:
     User:
      class: sfGuardUser
      foreign: id
      local: user_id
      type: one
      onDelete: cascade
      onUpdate: cascade
      foreignType: one
      foreignAlias: Profile
  indexes:
    user_id_unique:
      fields: [user_id]
      type: unique

SfGuardUser 表:

SfGuardUser table:

GuardUser:
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    username:
      type: string(128)
      notnull: true
      unique: true
    algorithm:
      type: string(128)
      default: sha1
      notnull: true
    salt: string(128)
    password: string(128)
    is_active:
      type: boolean
      default: 1
    is_super_admin:
      type: boolean
      default: false
    last_login:
      type: timestamp
  indexes:
    is_active_idx:
      fields: [is_active]
  relations:
    groups:
      class: sfGuardGroup
      local: user_id
      foreign: group_id
      refClass: sfGuardUserGroup
      foreignAlias: Users
    permissions:
      class: sfGuardPermission
      local: user_id
      foreign: permission_id
      refClass: sfGuardUserPermission
      foreignAlias: Users

我有下一个 sfGuardUserForm:

I have next sfGuardUserForm:

  public function configure()
  {

      parent::configure();

  $profileForm = new sfGuardUserProfileForm($this->object->Profile);
  unset($profileForm['user_id'],$profileForm['banned'],$profileForm['validate'],$profileForm['payed_until']);


     $profileForm->widgetSchema['salutation'] = new weWidgetSalutationI18n();
       $profileForm->widgetSchema['country'] = new sfWidgetFormI18nChoiceCountry();
       $profileForm->setDefault('country', 'DE');
  $this->embedForm('Profile', $profileForm);

  }

所以,当我从后端添加新用户时,在我的 sfGuardUserProfile 表中 user_id = 0 ...

So, when I add new user from backend, in my sfGuardUserProfile table user_id = 0 ...

推荐答案

试试看是否适合您:

public function configure()
{
   parent::configure();
   $profile = new sfGuardUserProfile();
   $profile->setUserId($this->getObject()->id);
   $profileForm = new sfGuardUserProfileForm($profile);
   $this->embedForm('Profile', $profileForm);
}

这篇关于后端 sfGuardUser 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆