Trying to join two independent forms

Posted by user248959 on Stack Overflow See other posts from Stack Overflow or by user248959
Published on 2010-05-26T14:19:52Z Indexed on 2010/05/26 14:21 UTC
Read the original article Hit count: 174

Filed under:

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?

© Stack Overflow or respective owner

Related posts about symfony