[eluser]TheFuzzy0ne[/eluser]
I'm starting to wonder if it's an error in your code that's not allowing the validation to run. I ran this test:
Code:
<?php
class Test extends Controller
{
function Test()
{
parent::Controller();
}
function index()
{
$this->load->library('form_validation');
if ($this->input->post('submit'))
{
$this->form_validation->set_rules('select', '', 'required');
if ($this->form_validation->run())
{
echo "sorted!<br />";
die('<pre>'.print_r($this->input->post('select'), TRUE).'</pre>');
}
echo validation_errors();
die('<pre>'.print_r($_POST, TRUE).'</pre>');
}
$this->output->set_output($this->_print_page());
}
function _print_page()
{
return <<<EOT
<html>
<head>
<title>Test</title>
</head>
<body>
<form action="test" method="post">
<select name="select[]" multiple="multiple">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
EOT;
}
}
/* End of file test.php */
/* Location: ./system/application/controllers/test.php */
When I submitted the form without any items selected, the form validation library told me that it was a required field, which it should. This confirms that the validation library performs the test even if it doesn't exist in the post array.