Welcome Guest, Not a member yet? Register   Sign In
I have problem with CI+Smarty.... validation_error
#1

[eluser]ivelin[/eluser]
hi guys.... how to show
Code:
form_error('field name', '<div class="error">', '</div>')
for every forms in .tpl file???
Quote:HP Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "application/views/admin/reviewers/reviewer.tpl" on line 60 "{$form_error('firstname', '&lt;div class=&quot;error&quot;&gt;', '&lt;/div&gt;')}" - Unexpected "(", expected one of: "}" ,
#2

[eluser]Abel A.[/eluser]
Code:
$this->tpl->smarty->assign('errors',validation_errors());

Then you can just call the errors using $errors in your tpl file.
#3

[eluser]ivelin[/eluser]
a how use form_error in .tpl
#4

[eluser]anis2505[/eluser]
This is not recommended but you can just embed php code inside a smarty template file using {php} {/php} "tags"
#5

[eluser]dnc[/eluser]
Although I have not attempted to implement Smarty with CodeIgnitor and have no way of testing this, you may want to try,


Code:
{ldelim}
{$form_error(‘firstname’, ‘<div class="error">’, ‘</div>’)}
{rdelim}

or maybe

Code:
{literal}
{$form_error(‘firstname’, ‘<div class="error">’, ‘</div>’)}
{/literal}

not sure if it will work, but worth a shot?




#6

[eluser]Abel A.[/eluser]
It's not going to work because form_error is a function. You need to pass the value to a variable first, then can call that variable within smarty.




Theme © iAndrew 2016 - Forum software by © MyBB