|
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 |
mastab0323 Smarty Rookie
Joined: 01 Jul 2005 Posts: 27
|
Posted: Wed Jul 27, 2005 5:31 pm Post subject: Form errors presentation or business logic? |
|
|
I had a discussion today with my co-worker and couldnt come to an agreement that form error messages are presentation or business logic.
In my php should I just pass an error type like:
1. $form_errors[] = 'username_required';
or
2. $form_errors[] = 'The username field is required.';
If we did #1 he would have to know all of the types I passed and do an if elseif statement that contained all of the messages. So if a month later I wanted to add an error I would have to inform him of it. #2 allows him to just loop through the errors and then I can add/remove any errors I wanted.
What do you think? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Jul 27, 2005 5:42 pm Post subject: |
|
|
Well, if you use types, then you can integrtate it with a config file to hide the details from the template designer.
consider:
errors.conf
Code: | foo = "Incorrect Foo"
bar = "Missing Bar" |
index.php
[php:1:1b980b9c91]$errors[] = 'foo';
$smarty->assign('errors', $errors);
$smarty->display('form.tpl');[/php:1:1b980b9c91]
form.tpl
Code: | {config_load file=errors.conf}
{foreach from=$errors item=error}
{$smarty.config.$error}<br/>
{/foreach} |
This also gives you some localization abilities. |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
|
Back to top |
|
umair123 Smarty n00b
Joined: 06 May 2022 Posts: 4
|
Posted: Fri May 06, 2022 8:36 am Post subject: |
|
|
Well said. But we need now some advance level business logic, I am not talking about error because you are not mentioned your error properly, so, business logic is only you can get from dataromas. If you need any kind of suggestion about business, feel free for contact us. |
|
Back to top |
|
umair123 Smarty n00b
Joined: 06 May 2022 Posts: 4
|
Posted: Fri May 06, 2022 8:42 am Post subject: |
|
|
Well said. But we need now some advance level business logic, I am not talking about error because you are not mentioned your error properly, so, business logic is only you can get from dataromas. If you need any kind of suggestion about business, feel free for contact us. |
|
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
|