[eluser]asumaran[/eluser]
I'm trying to validate my form putting the form validation rules in a file form_validation in /myapp/config/
my form_validation.php file looks like this:
Code:
$config = array(
'entrada/publicar' => array(
array(
'field' => 'section',
'label' => 'Sección',
'rules' => 'required'
),
array(
'field' => 'title',
'label' => 'Título',
'rules' => 'required'
),
array(
'field' => 'post_content',
'label' => 'Contenido',
'rules' => 'required'
),
array(
'field' => 'resume',
'label' => 'Resumen',
'rules' => 'required'
),
array(
'field' => 'format',
'label' => 'Formato',
'rules' => 'required|numeric'
),
array(
'field' => 'category',
'label' => 'Categoría',
'rules' => 'required|numeric'
),
array(
'field' => 'target',
'label' => 'Dirigido',
'rules' => 'required|numeric'
),
array(
'field' => 'date',
'label' => 'Fecha',
'rules' => 'required|callback_is_valid_date'
)
)
);
my controller (myapp/controllers/entrada.php )
Code:
function publicar()
{
if ($this->form_validation->run() == FALSE)
{
...code
}
else
{
...code
}
}
whith this way nothin happens (or always is valid, the error messages is not displayed), otherwise if I set inline rules en my code, then works
my controller file with rules:
Code:
function publicar()
{
$this->form_validation->set_error_delimiters('<span class="inline_error">', '</span>');
$this->form_validation->set_rules('title', 'Título', 'required');
$this->form_validation->set_rules('post_content', 'Contenido', 'required');
$this->form_validation->set_rules('resume', 'Resumen', 'required');
$this->form_validation->set_rules('format', 'Formato', 'required|numeric');
$this->form_validation->set_rules('category', 'Categoría', 'required|numeric');
$this->form_validation->set_rules('target', 'Dirigido', 'required|numeric');
$this->form_validation->set_rules('date', 'Fecha', 'required|callback_is_valid_date');
if ($this->form_validation->run() == FALSE)
{
//works if form is invalid
}
else
{
//works if worm is valid
}
}
I'm not using routes, _remap,etc.
please, help!
is a bug?
please, sorry for my english :/