|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
beredon Smarty n00b
Joined: 03 May 2007 Posts: 3
|
Posted: Thu May 03, 2007 11:18 pm Post subject: SmartyValidate logic problem |
|
|
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 |
|
beredon Smarty n00b
Joined: 03 May 2007 Posts: 3
|
Posted: Fri May 04, 2007 2:09 am Post subject: |
|
|
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 |
|
beredon Smarty n00b
Joined: 03 May 2007 Posts: 3
|
Posted: Tue May 08, 2007 12:34 pm Post subject: |
|
|
All good. |
|
Back to top |
|
|
|
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
|