I have a Login form and registration form on the same page. They are in separate <div> tags, that appear and hide using jquery:
jQuery('#register-btn').click(function () {
jQuery('.login-form').hide();
jQuery('.register-form').show();
});
I have a controller action that reads the POST request sent by the registration form. I want the controller to send the user back to the registration form if there are errors in the inputs. Here is the snippet from my controller:
public function actionLogin()
{
...
$accessRequest = new AccessRequest();
if (isset($_POST['AccessRequest']))
{
$accessRequest->attributes = $_POST['AccessRequest'];
//validate user input and save access request
if ($accessRequest->save())
{
Yii::app()->user->setFlash('success', '<strong>Done!</strong> A Request has been submitted. Someone will be in touch with you shortly');
$accessRequest->unsetAttributes();
}
else
{
if ($accessRequest->hasErrors())
{
Yii::app()->user->setFlash('errorReg', CHtml::errorSummary($accessRequest));
}
}
}
...
$this->render('login', array('loginModel' => $loginModel, 'accessRequest' => $accessRequest));
How can I send the user back to the registration section of the Login page from the controller?
Any help would be great.
Thanks.
–Bhavik