I have form select with 2 values of 0 and 1
<select class="form-control form-control-sm col-sm-3" name="status">
<option value="1">On<option>
<option value="0">Off</option>
</select>
Now in codeigniter controller i set rule to accept only values of 0 or 1, so i used in_list[] function, but when i select Off i get error The Status field must be one of: 0,1., and when i select On i don't get any error.
Here is controller code
$this->form_validation->set_rules('status', 'Status', 'trim|required|xss_clean|in_list[0,1]');
if ($this->form_validation->run() === false) {
$data = [
'error' => true,
'status_error' => form_error('status')
];
}
echo json_encode($data);