Welcome Guest, Not a member yet? Register   Sign In
Form Validation: return calues for rules?
#1

[eluser]mindph[/eluser]
Hi

Is it possible somehow, to have the form validator return which rule was failing validation?

The purpose why I could need this is simply: I dont want to display only the errors, but also hilight the field what failed validation.
So that I could get something like
Code:
if($this->form_validation->rule('firstName') == FALSE){
$formData['firstName'] = array('style' => 'background-color: red');
}
I am not sure if you get what I mean... oO
#2

[eluser]misplacedme[/eluser]
Check out the section labeled "Showing Errors Individually" in the form validation page.

Code:
<h5>Username</h5>
&lt;?php echo form_error('username'); ?&gt;
&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?&gt;" size="50" /&gt;
#3

[eluser]mindph[/eluser]
Okay thanks that looks cool.

Gonna like CI!
#4

[eluser]mindph[/eluser]
BTW The userguide tells me only about these values to set in an array.
Code:
$data = array(
              'name'        => 'username',
              'id'          => 'username',
              'value'       => 'johndoe',
              'maxlength'   => '100',
              'size'        => '50',
              'style'       => 'width:50%',
            );

echo form_input($data);
But class is also possible
Code:
'class' => 'classname'
Could be told in the User Guide too.




Theme © iAndrew 2016 - Forum software by © MyBB