Smarty dynamic error list
Posted
by
Brainscrewer
on Stack Overflow
See other posts from Stack Overflow
or by Brainscrewer
Published on 2012-10-11T21:34:23Z
Indexed on
2012/10/11
21:36 UTC
Read the original article
Hit count: 176
Im new to Smarty in combination with PHP and I really like it. Unfortunatly im running into a problem while validating fields after a $_POST has been done.
I've made an array called $errors and use that to save error messages in, for example: $errors[] .= "Wrong email";. My problem is in sending the $errors array over to the template so I can use it to display the error messages.
My question: How do you 'transfer' the $errors variable over to the template file so you can use it there with, for example {foreach}. I was planning on doing something like
{if $hasErrors}
{foreach from=errors item=error}
<li>{$error}</li>
{/foreach}
{/if}
Thanks in advance
© Stack Overflow or respective owner