Welcome Guest, Not a member yet? Register   Sign In
Smarty form validation
#1

[eluser]growknight[/eluser]
Hi everyone!
I use CI with smarty, it works good, but i have a problem. I can reach the validation_error() ci stuff to show the form errors. Any idea?
Thanks!
#2

[eluser]gon[/eluser]
Are you assigning validation object to a smarty variable?
So you can access validation properties (values and errors).
#3

[eluser]ascotan[/eluser]
If your using smarty you need to capture the validation error into smarty for use somewhere else:

Code:
{capture assign=validation_errors}{php}echo validation_errors();{/php}{/capture}

You can use {$validation_errors} anywhere you want.

I however use a little bit different system.
I capture the form errors individually:

Code:
{capture assign=ship_firstname_error}{php}echo form_error('ship_firstname');{/php}{/capture}

And then use smarty for templating based on wether an error was detected:

Code:
<div class="warn">
  {$ship_firstname_error}
  .....
</div>
<div class="{if $ship_firstname_error}form_error{/if}" id="form_ship_firstname">
    ......
</div>




Theme © iAndrew 2016 - Forum software by © MyBB