Smarty dynamic error list
- by Brainscrewer
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