tags:

views:

40

answers:

2

Hi,

i'm trying to join two independent forms (login and register) in the same page.

My idea is (just looking at the signin form):

  • Create an action that shows both forms (partials):

    public function executeLoginAndRegister(sfWebRequest $request){
    
    
       $this->form_signin =  $this->getUser()->getAttribute('form_signin');
    
    
    }
    
  • Each partial calls to its action:

form action="php?> echo url_for('@sf_guard_signin') ?>" method="post">

  • In the actions i write this code

    public function executeSignin($request)
    {
       //...
    
    
      $this->form = new $MyFormclass();
    
    
       if ($this->form->isValid())
       {
           //...
    
    
       }else{
    
    
    
        // save the form to show the error messages.
        $this->getUser()->setAttribute('form_signin', $this->form);
    
    
        return $this->forward('sfGuardAuth', 'loginAndRegister');
    
    
    }
    
    }

It works, but, for example, if i execute LoginAndRegister and submit incorrectly the signin form and I go to another page and then return to LoginAndRegister, i will find the submiting error messages...

If i execute LoginAndRegister and submit incorrectly the signin form and open another browser tab, i will find the submiting error messages in the signin form of the second tab...

Any idea? any better approach?

+1  A: 

I would just use sfDoctrineApplyPlugin if i were you :)

prodigitalson
I'm using sfDoctrineGuardExtraPlugin to register users. It works perfect. I think my problem is not that. My problem is placing independent forms in the same page.
Wait... are not embedding both forms into a single form???
prodigitalson
No, I'm NOT embedding both forms into a single form. Do you think embedding both forms would work? But they are totally independents! :S
+1  A: 

I have it, just writing in the if "request->isMethod('post')":

 public function executeLoginAndRegister(sfWebRequest $request){

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

    $this->form_signin =  $this->getUser()->getAttribute('form_signin');

  }
}

Anyway if my approach has any big error or is not safety i would thank anyone who tell me.

Javi