2009-11-09 57 views
0

我成功創建了一個註冊表單,現在用戶可以註冊我的網站。 但我無法創建用戶可以編輯其個人資料的表單。從frontend編輯配置文件 - symfony

我有sf_guard_user和sf_guard_user_profile在我的schema.yml

是否有人對如何做到這一點的文章?我嘗試了一些沒有成功的想法。

回答

2

快速的方式開始是創建一個前端CRUD與任務

./symfony學說:產生-CRUD即。

./symfony doctrine:generate-crud frontend user sfGuardUser 

(或者你可以生成與教義的曲線形式:建立表單任務)

從這裏你可以自定義表單。最棘手的部分將合併兩種形式, sf_gurd_user_form(帶密碼和用戶名的那個)和sf_guard_profile_form。如果你想配置文件字段和相同的表格,你應該使用嵌入表單上用戶領域這裏所說:

http://www.blogs.uni-osnabrueck.de/rotapken/2009/03/13/symfony-merge-embedded-form/comment-page-1/

從博客頁面的代碼段:

class sfGuardUserForm extends BasesfGuardUserForm 
{ 
    public function configure() 
    { 
    parent::configure(); 
    $profileForm = new UserProfileForm($this->object->Profile); 
    unset ($profileForm['id'], $profileForm['sf_guard_user_id']); 
    $this->embedForm("profile", $profileForm); 
    } 
} 
+1

+1 - 我使用定期在鏈接文章中的技巧。請注意,如果您使用提供的代碼,則驗證器後面的問題不會被複制。 – benlumley 2009-11-09 20:34:33