I have seen this question all over the web and am surprised that nobody has actually offered such a simple solution.
Anyway, here is a quick, simple and painless way to set CodeIgniter’s error delimiters (used by the Form_validation library) one time for your entire application. Create “application/libraries/MY_Form_validation.php” with the following contents…
class MY_Form_validation extends CI_Form_validation { public function __construct() { parent::__construct(); $this->_error_prefix = '<div class="ui-widget"><div class="ui-state-error ui-corner-all" style="display: inline-block; padding: 2px 4px"><span style="float: left; margin-right: 2px"></span> '; $this->_error_suffix = '</div></div>'; } }
No more setting the delimiters every time you load the Form_validation library!
You can still override the new delimiters by using
$this->form_validation->s
et_error_delimiters()
in your controllers as needed.
Note: If you’re curious about the HTML I used above, it was adapted from the jQueryUI – Themeroller page source.