Perhaps I should add a little more information. As I said, before I moved the validation rules into the config file everything worked just fine.
I’ve got a controller (buy.php) with an index() method that looks like this (I’ve stripped out some additional code that isn’t relevant to the question to make things clearer):
<?
function index()
{
if ($_POST) {
if ($this->form_validation->run() == TRUE) {
redirect('buy/search');
}
else {
$this->load->view('buy');
}
}
else {
$this->load->view('buy');
}
}
?>
I’m loading the form validation library in config/autoload.php
My config file (config/form_validation.php) looks like this:
<?
$config = array(
'buy' => array(
array(
'field' => 'make',
'label' => 'Make',
'rules' => 'required|not_default'
),
array(
'field' => 'model',
'label' => 'Model',
'rules' => 'required|not_default'
),
array(
'field' => 'type',
'label' => 'Type',
'rules' => 'required|not_default'
),
array(
'field' => 'postcode',
'label' => 'Postcode',
'rules' => 'required|valid_postcode'
)
)
);
?>
In reality I have more than one named group of rules in the $config array to apply to each method in the controller.
The custom functions are defined in MY_form_validation.php which extends the core form validation class.
I’m not getting any errors, and I know the config file is being loaded because I can echo stuff out from it. When I submit the form the page just reloads - obviously $this->form_validation->run() is returning FALSE.
Hope that helps put things in context a bit more.