我使用的原則和有一個小問題,embedForm
自定義表單和更新記錄SF1.4symfony的 - 與embedForm
我已經創建了一個模塊,用戶可以從特定編輯/創建/刪除用戶使用sfDoctrineGuard
形式組是簡單地命名爲manufacturerForm.class.php
自定義表單和它延伸sfGuardUserAdminForm
class manaufacturerForm extends sfGuardUserAdminForm
{
public function configure()
{
$form = new sfGuardUserProfileForm();
$this->embedForm('profile', $form);
unset($this['firstname'], //this field is in sfGuardUserProfile is shown in form
$this['user_id'], //this field is in sfGuardUserProfile is shown in form
$this['is_super_admin'], //this field is in sfGuardUser is not shown
$this['is_admin'], // this filed is in sfGuardUser is not shown
$this['permissions_list'], //this field is in sfGuardUser is not shown
$this['groups_list']);//this field is in sfGuardUser is not shown
}
}
你能看到我的嵌入sfGuardUserProfileForm
裏面我manufacturerForm
。
我有兩個問題,sfGuardUserProfile
有我不想顯示這個特殊的形式,如: firstname, lastname, email_new, created_at, updated_at
,但我似乎無法取消他們,因爲他們仍然顯示。
請注意,此管理模塊沒有generator.yml
文件。我在editSuccess.php
和_form.php
部分做了所有這些。
我的另一個問題是,當我編輯現有的用戶,並保存一切都很好。這個問題是有,當我嘗試編輯我得到如下:
An object with the same "user_id" already exist.
- 這是在sfGuardUserProfile的user_id
領域,同樣適用於email_new
領域。我得到An object with the same "email_new" already exist.
1)如何取消我不需要的字段?
2)我是否需要覆蓋任何doSave(),updateObject(),saveEmbeddedForms()方法來停止最後一個問題?
感謝
好的,但我有多個'用戶'可以這麼說,'製造商','供應商'每個需要sfGuardUserProfileForm類的不同領域。我的manaufacturerForm類擴展了什麼類?我的supplierForm類也一樣嗎?我仍然需要來自sfGuardUser的一些字段,以及來自sfGuardUserProfile的其他字段。謝謝 – terrid25 2011-04-21 11:14:54
我已經添加了一個代碼示例,這有幫助嗎? – 2011-04-21 11:41:24
謝謝你。我嘗試了代碼並收到:「sfGuardUser」上的未知記錄屬性/相關組件「sf_guard_user_profile」。這是什麼意思?教條主義,我很新。謝謝 – terrid25 2011-04-21 12:07:52