Welcome Guest, Not a member yet? Register   Sign In
Form Validation Errors Not Showing?
#1

[eluser]Unknown[/eluser]
Code:
public function test()
    {
       $this->form_validation->set_rules('tin_number','TIN Number','required');

        if($this->form_validation->run() == TRUE)
        {
            echo $this->input->post('tin_number');
        }
       else {
        echo validation_errors();
        echo form_open();
        echo form_input('tin_number',set_value('tin_number'));
        echo form_submit('submit','Submit');
        echo form_close();
       }
      
    }

Can anyone help me figure out why this is not working?
#2

[eluser]alvaroeesti[/eluser]
in what it is failing?



And have you loaded the validation library?

The library checks for errors

it looks like you wanted to echo a correct value

try it the other way around, put == FALSE

and try to enter a wrong value
#3

[eluser]seegan[/eluser]
// Just code like this..

Code:
public function test()
    {
     $this->load->library('form_validation');
        $this->form_validation->set_rules('tin_number','TIN Number','required');

        if($this->form_validation->run() == TRUE)
        {
            echo $this->input->post('tin_number');
        }
       else {
        echo validation_errors();
        echo form_open();
        echo form_input('tin_number',set_value('tin_number'));
        echo form_submit('submit','Submit');
        echo form_close();
       }
    }



//You need to load 'form_validation' library
#4

[eluser]Unknown[/eluser]
// Just code like this..

Code:
public function test()
{
$this->load->library('form_validation');

$this->form_validation->set_rules('tin_number','TIN Number','required');

try
{
  if(!$this->form_validation->run())
   throw new Exception($this->form_validation->error_string());
}
catch(Exception $e)
{
  echo $e->getMessage();
                echo form_open();
                echo form_input('tin_number',set_value('tin_number'));
                echo form_submit('submit','Submit');
                echo form_close();
  return;
}
}
#5

[eluser]N3XT0R[/eluser]
if you load in your controller-class inside the constructor any models, check if one of the models extends the ci_controller.
Little time ago i done the mistake/fail and tried to load a model wich extends from the ci_controller.... <-- yes fail

If you do something like this, the form_validation will return a right value, but your form_validation error will not be displayed in your view.
validation_errors() will return a String with a length of 0.




Theme © iAndrew 2016 - Forum software by © MyBB