 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
Jakob Smarty n00b
Joined: 13 Apr 2005 Posts: 3
|
Posted: Wed Apr 13, 2005 7:43 pm Post subject: Modify SmartyValidate error message |
|
|
Is there a way to automatically filter the error messages of SmartyValidate? I want the messages into a configuration file and format them with CSS. Here is a short example:
template.tpl:
{validate id="name" message=$smarty.config.error_msg}
localization.conf:
error_msg = "bad & wrong"
On validation error in field "name" the message "bad & wrong" is displayed, but I want something like
<span class="error">bad & wrong</span>
I little function like
[php:1:41cb0c38ec]function validation_error_msg($msg) {
return "<span class='error'>" . htmlspecialchars($msg) . "</span>";
}[/php:1:41cb0c38ec]
should do it - but where to put it? |
|
| Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5613 Location: Toronto, Canada
|
Posted: Wed Apr 13, 2005 7:45 pm Post subject: |
|
|
| {validate id="name" message=$smarty.config.error_msg|validation_error_msg} |
|
| Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7047 Location: Lincoln Nebraska, USA
|
Posted: Wed Apr 13, 2005 7:50 pm Post subject: |
|
|
Another option:
| Code: | {validate id="name" message=$smarty.config.error_msg assign="error"}
{if $error ne ""}<span class="error">{$error}</span>{/if} |
|
|
| Back to top |
|
Jakob Smarty n00b
Joined: 13 Apr 2005 Posts: 3
|
Posted: Wed Apr 13, 2005 10:08 pm Post subject: |
|
|
| Thanks! Smarty is great! |
|
| 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
|