2011-02-07 15 views
1

ユーザーがsymfonyを登録してsf_guard_userテーブル(1つ空)に2回保存し、プロファイルを空の行。symfonyはsafeguard_userテーブルで2回(空)1回、プロファイルテーブルで1回

私はフォーム2を送信しません。アクションは1回だけ実行されます。 デバッグバーは、空のデータで1回、実際にDBに2時間を保存することを教えてくれます。

本当にイライラ

スキーマ:

BambinbazarUsers: 
    actAs: 
    Geographical: ~ 
    columns: 
    sf_guard_user_id: integer 
    company: { type: string(255) } 
    url:  { type: string(255) } 
    usertype: { type: string(255) } 
    address: { type: string(255) } 
    city:  { type: string(255) } 
    facebookid:{ type: string(255)} 
    state:  { type: string(255) } 
    zipcode: { type: string(255) } 
    Country: { type: string(255) }   
    telephone: { type: string(255) }  
    relations: 
    BambinbazarArticles: 
    class: BambinbazarArticles 
    local: sf_guard_user_id 
    foreign: userid 
    type: many 
    foreignType: one 
    sfGuardUser: 
     onDelete: CASCADE 
     local: sf_guard_user_id 
     foreign: id 
     foreignAlias: BambinbazarUsers 
     foreignType: one  

アクション(も変更):

if ($this->getUser()->isAuthenticated()) 
    { 
     $this->getUser()->setFlash('notice', 'You are already registered and signed in!'); 
     $this->redirect('@homepage'); 
    } 
    $this->form = new sfGuardRegisterForm(); 

    if ($request->isMethod('post')) 
    { 

     $this->form->bind($request->getParameter($this->form->getName())); 
     if ($this->form->isValid()) 
     { 

     $user = $this->form->save(); 

     $this->getUser()->signIn($user); 

     $this->redirect('@view_my_profile'); 
     } 
    } 

形式のconfigure:

public function configure() 
    { 
     $profileForm = new BambinbazarUsersForm($this->object->BambinbazarUsers); 
     unset($profileForm['id'], $profileForm['sf_guard_user_id']); 
     $this->embedForm('Profile', $profileForm); 

    } 
+1

オフトピック(またはそうでないかもしれない?)、しかし、あなたが削除する必要がありますBambinbazarUserの後で、doctrineが関係型(一対多、一対一)を検出すると、いくつかの問題が生じる可能性があります。教義のクラス名は、私が思うには常に単数でなければなりません。 – greg0ire

+0

greg0ireが正しいです。スキーマに特異な名前がある場合は、生成されたコードの文法に関するすべてがうまく機能します。 – Nathan

答えて

0

私はBambinbazarUsersFormでsfGuardユーザテーブルに関連した組み込み関係を持っていた問題

を見つけました。

空のレコードを効果的に作成します。

ソリューションは、基本ユーザーフォーム、私は推測する初心者のエラーを埋め込むプロファイルフォームを作成することでしたが、本当にハードに、デバッグに...

0

sfGuardのsignIn()この方法はまた、最終ログイン時刻を更新するために、ユーザオブジェクトを保存します。

public function signIn($user, $remember = false, $con = null) 
{ 
    // signin 
    $this->setAttribute('user_id', $user->getId(), 'sfGuardSecurityUser'); 
    $this->setAuthenticated(true); 
    $this->clearCredentials(); 
    $this->addCredentials($user->getAllPermissionNames()); 

    // save last login 
    $user->setLastLogin(time()); 
    $user->save($con); 
    // ... 

フォームを保存する前にsignIn()を行う場合、それは動作しますか?

+0

さて、私はリダイレクトの前にダイを追加しようとしましたが、SQLインサートはまだ2回実行されていましたが、私はSの問題を知りませんでした。 –

関連する問題