[eluser]Unknown[/eluser]
I had a problem with a code. I think it a bug.
My view template (register_view.php):
Code:
<form method='post' action='./'>
<input type="checkbox" name="contract" value="accept" />
<input type="submit" value="Submit" name="create">
</form>
My controller:
Code:
$this->load->library('validation');
$rules['contract'] = "callback_contract";
$this->validation->set_rules($rules);
$fields['contract'] = 'Contract';
$this->validation->set_fields($fields);
if ($this->validation->run() == FALSE)
{
$this->load->view('register_view', $data);
}
else
{
echo 'Ok!';
}
And callback function for contract-checkbox:
Code:
function contract($contract)
{
if($contract == 'accept')
{
return true;
}
else
{
$this->validation->set_message('login_check', 'Чекбокс необходим');
return false;
}
}
The problem is that when the checkbox is not checked (that means, the "$contract" variable doesn't have "accept" value), we don't get an error message, so the case is processed incorrectly. Could you please the issue. Thank you!