Form Validation & Redirection issue[closed]

Notes and reports about symfony 1.0.x stable

Moderators: dwhittle, Ian

Form Validation & Redirection issue[closed]

Postby gentrobot » Fri Dec 11, 2009 11:49 am

I have a template with a form, a JS executed onclick of submit button, an action execution after form submission and another template to which the user should be redirected ideally after successful form submission. If the validation fails it should give error message.

The problem I am facing is that it displays the required error message but even after displaying the error message, it redirects to the Thank You page. Can You guys help make it work as required? I do understand Symfony,HTML and JS but am no expert. I am learning by doing and hence would appreciate a little elaborated answer :)~ :-)~ :smile:

The form tag used:

<form name="myForm" method="post" enctype="multipart/form-data" action="/module/templateSubmit">

onclick event of submit:
function Name(){
var isError= false;


error="Error Text";
....validation conditions that set isError=True on failed validation.....

if(isError){
document.getElementById('errorDiv').innerHTML=error;
document.getElementById('errorDiv').style.display='block';
}
else{
document.loadlist.submit();
}

***where errorDiv is the div ID where error message is displayed on the form page

action for templateSubmit:
$this->redirect('module/ThankYouTemplate');

action for ThnakYouTemplate:
return sfView::SUCCESS;


I guess that is all the info you need. If at all more information is required, just let me know.
Thank You
gentrobot
Member
 
Posts: 45
Joined: Thu Oct 08, 2009 7:43 am

Return to symfony 1.0

Who is online

Users browsing this forum: Bing [Bot] and 0 guests