[eluser]ReyPM[/eluser]
Hi, I've this code in my template:
Code:
<label>Código UNESCO:</label><?php echo form_error('unescocode'); ?>
<?php if ($arrayUnescocodes): ?>
<select id="id_unesco" name="id_unesco">
<option value="0">Seleccione un valor ...</option>
<?php foreach ($arrayUnescocodes as $clave => $valor): ?>
<option value="<?php echo $clave; ?>"><?php echo $valor; ?></option>
<?php endforeach; ?>
</select>
And this other code in my controller:
Code:
$this->load->library('form_validation');
$this->form_validation->set_rules('id_unesco', 'Código UNESCO', 'trim|xss_clean|callback_check_unesco');
public function check_unesco($value) {
if ($value == 0) {
$this->form_validation->set_message('check_unesco_value', 'Debe seleccionar un Código UNESCO');
return FALSE;
} else {
return TRUE;
}
}
When I send the form and leave id_unesco as 0 non error is displayed and form is send, why? where I´m wrong?