Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you customize/style codeigniter errors?

I'm trying to customize the CSS/HTML for error message displays in codeigniter so I can apply a tag too each and style them up.

I tried to Google this and search the manual but must have been searching for the wrong terms - can anyone help me out?

like image 739
Walker Avatar asked Aug 16 '10 23:08

Walker


2 Answers

You can do something like this...

$this->form_validation->set_error_delimiters('<div class="error">', '</div>'); 

See the related Codeigniter documentation

Note: Updated to correct function reference (validation should be form_validation).

like image 139
vikmalhotra Avatar answered Oct 12 '22 01:10

vikmalhotra


I recommend more elegant way.

Сreated a MY_Form_validation.php file and dropped it into application/libraries with the following code overriding the default delimiters.

class MY_Form_validation extends CI_Form_validation {

    public function __construct()
    {
        parent::__construct();

        $this->_error_prefix = '<p class="error">';
        $this->_error_suffix = '</p>';
    }
}

Link to original: http://chris-schmitz.com/changing-default-error-delimiters-in-codeigniter/

like image 31
A1ik Avatar answered Oct 12 '22 02:10

A1ik