I´m following a tutorial, but I am getting this error: Unable to access an error message corresponding to your field name
I´ve searched, but I can´t find a solution. The program is very simple: cformulario.php
<?php
class cFormulario extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
}
function mostrarDatos(){
$this->form_validation->set_rules('txtnom', 'Nombre', 'trim|required|min_lenght[3]|max_lenght[50]');
$this->form_validation->set_rules('txtmail', 'Correo', 'trim|required|valid_email');
if($this->form_validation->run()==FALSE){
$this->load->view('vformulario');
}
else{
$datos=array(
'nombre' => $this->input->post('txtnom'),
'edad' => $this->input->post('txted'),
'correo' => $this->input->post('txtmail')
);
$this->load->view("vformulario", $datos);
}
}
}
?>
vformulario.php
<body>
<h1>Información Personal</h1>
<br>
<div id="error">
<?php
echo validation_errors();
?>
</div>
<br>
<?php
echo form_open('cFormulario/mostrarDatos');
?>
Nombre
<input type="text" name="txtnom" id="txtnom" value="<?php echo set_value('texnom', '');?>"/>
<br>
Edad
<input type="text" name="txted" id="txted" />
<br>
Correo
<input type="text" name="txtmail" id="txtmail" value="<?php echo set_value('texmail', '');?>"/>
<br>
<input type="submit" name="Mostrar datos" />
<input type="reset" name="Restablecer" />
<?php
echo form_close();
?>
<br>
<div id="resultado">
<?php
if(!empty($nombre) && !empty($edad) && !empty($correo)){
echo "Nombre: $nombre<br>";
echo "Edad: $edad<br>";
echo "Correo: $correo<br>";
}
?>
</div>
</body>
Weird thing is, it was working fine while I was typing it. But when I tried to show some results, the error came.