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

Form errors presentation or business logic?

 
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 -> General
View previous topic :: View next topic  
Author Message
mastab0323
Smarty Rookie


Joined: 01 Jul 2005
Posts: 27

PostPosted: Wed Jul 27, 2005 5:31 pm    Post subject: Form errors presentation or business logic? Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Jul 27, 2005 5:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Thu Jul 28, 2005 7:03 am    Post subject: Reply with quote

Hi,

you could also do the forum validation with SmartyValidate:

http://www.phpinsider.com/smarty-forum/viewtopic.php?t=5306

Bye,
Markus
Back to top
View user's profile Send private message
umair123
Smarty n00b


Joined: 06 May 2022
Posts: 4

PostPosted: Fri May 06, 2022 8:36 am    Post subject: Reply with quote

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
View user's profile Send private message
umair123
Smarty n00b


Joined: 06 May 2022
Posts: 4

PostPosted: Fri May 06, 2022 8:42 am    Post subject: Reply with quote

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
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 -> General 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