Welcome Guest, Not a member yet? Register   Sign In
form problem - unable to display error messages
#1

[eluser]webdude[/eluser]
For some reason when my validation == FALSE and I try to display <?=$this->validation->error_string; ?> on my page it does not diplay.


In my control I have the following:
Code:
<?php

    class Product_details  extends Controller {
    
        function Product_details()
        {
                parent::Controller();
                $this->load->helper(array('form', 'url'));
                $this->load->library('validation');                
        }
        
        function index()
        {
    
        }
        
        function productdetails()
        {            
                
        }
        
        function add()
        {
            $rules['qty'] = "numeric";
            
            $this->validation->set_rules($rules);
                
            if ($this->validation->run() == FALSE)
            {
                $this->load->view('product_details_view');
            }
            else
            {
                //$this->load->view('formsuccess');
                echo "success";
            }                
            
        }    
            
    }
?>
In my view I have the following:
Code:
<?=$this->validation->error_string; ?>

Thanks in advance
#2

[eluser]Phil Sturgeon[/eluser]
You problem most likly comes from not setting the $field variable, it needs both to validate properly.
#3

[eluser]webdude[/eluser]
thats not it.
#4

[eluser]Phil Sturgeon[/eluser]
Realised that after i said it, erm, im not sure what it is, the code is exactly the same as my own except for you have library in a constructor and I doubt thats it.

I would reccomend that you put rules for ALL elements in the form. If you have 5 fields and only two are required, you just use "required|whatever" for those and "trim" or something useful for the rest.




Theme © iAndrew 2016 - Forum software by © MyBB