i’m trying to join in the same action the login and the register forms. This is what i’m trying:
modules/miembros/actions.class.php
public function executeAux(sfWebRequest $request)
{
// I execute this action
}
modules/miembros/templates/auxSuccess.php
<?php include_component('sfGuardRegister', 'register'); ?>
<?php include_component('sfGuardAuth', 'signin'); ?>
modules/miembros/components.class.php
public function executeSignin($request)
{
if ( $request->isMethod( 'post' ) && ($request-
>getParameter('submit')=='signin') ){
$this->form->bind( $request->getParameter( 'login' ) );
if ( $this->form->isValid() ){
$this->getController()->getActionStack()->getLastEntry()->getActionInstance()->redirect( '@home' );
}
}
}
modules/miembros/templates/_signin.php
<form action="<?php echo url_for('miembros/aux?submit=signin') ?>"
method="post">
<?php echo $form['email_address']->renderLabel() ?>
<?php echo $form['email_address'] ?>
...
It’s working ok, but i would to know if you have other alternatives.
For example i don’t like the line:
$this->getController()->getActionStack()->getLastEntry()->getActionInstance()->redirect( ‘@home’ );
Regards
Javi
you shouldn’t process the form in your component , you should do it in your action. the components meant to be reusable views that can get included in other templates (similar to partials, but with some code behind them to sustain more complex data retrieves). If you want to show the form in a component so you can reuse it, you can, but you should handle the form in another action.