Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

SmartyValidate logic problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
beredon
Smarty n00b


Joined: 03 May 2007
Posts: 3

PostPosted: Thu May 03, 2007 11:18 pm    Post subject: SmartyValidate logic problem Reply with quote

Hi. I am using SmartyValidate and a master switch statement in my index.php to manage my page navigation.

Code:
switch($p) {
case 2:
  # Validate form
  break;
case 1:
  # Show page with form
  break;
}


I have about 150 lines of code in Case 1 for the smarty template that gets displayed. Case 2 validates a form in the Case 1 template and performs some database operations before displaying a success/failure template.

My question is, when the form is discovered invalid in Case 2, how to I go about executing all of the code in Case 1 to re-display the first template? I really want to avoid copy+pasting the code from Case 1 into Case 2. Also, I want to avoid using the one case statement for displaying the form and posting it back.

Does anyone have any ideas on how to go about solving this programming problem?

Cheers.
Back to top
View user's profile Send private message
beredon
Smarty n00b


Joined: 03 May 2007
Posts: 3

PostPosted: Fri May 04, 2007 2:09 am    Post subject: Reply with quote

OK. After long talks, the best option is to refactor the code so postbacks go to the originating case statement. There's a lot of code, so it will take a long time. But there's a lot more code to write, so it's a good idea to clean it up now and avoid future problems.

Thanks for listening.
Back to top
View user's profile Send private message
beredon
Smarty n00b


Joined: 03 May 2007
Posts: 3

PostPosted: Tue May 08, 2007 12:34 pm    Post subject: Reply with quote

All good. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP