[eluser]phpgeek[/eluser]
Hello everyone,
I'm having a bad time trying to show validation errors from multiple view files, it doesn't show them, see my code:
Code:
/*Prepago controller*/
function index()
{
//Conseguir los planes
$comboPlanes= $this->getPlanes();
//Elementos de página
$data = array(
'title' => 'Clientes por plan prepago',
'Fecha' => $this->setFormPrepago(),
'comboPlanes' => $comboPlanes,
'comboStatus' => $this->setFormPrepago(),
'comboModelo' => $this->getModeloEquipo()
);
$this->load->view('header', $data);
$this->load->view('prepago/instrucciones');
$this->load->view('welcome_message', $data);
$this->load->view('prepago/form_pre_plan', $data);
$this->load->view('footer');
}
Code:
/*form_pre_plan view*/
<?php echo validation_errors();
echo form_open('validation', array('name'=>'myform')); ?>
<table class="art-article" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>Plan</td>
<td><?php echo form_dropdown('cmbPlanes', $comboPlanes, '177'); ?></td>
</tr>
</tbody></table>
</p>
<p>
<a class="art-button">Procesar</a>
</p>
<?php echo form_close();?>
Once i submit, i validate this form using:
Code:
/*Validation controller*/
function index()
{
$this->load->model('PrepagoModel');
$this->load->library('form_validation');
$criteria= array('plan'=> $this->input->get_post('cmbPlanes', TRUE));
$this->form_validation->set_message('required', 'Your custom message here');
$config = array(array('field' => 'cmbPlanes', 'rules' => 'required'));
$this->form_validation->set_rules($config);
if ($this->form_validation->run() == FALSE){
//Go back to form_pre_plan and associate views (i can do this but it shows errors since it doesn't pass $data array)
$this->load->view('header', $data);
$this->load->view('prepago/instrucciones');
$this->load->view('welcome_message', $data);
$this->load->view('prepago/form_pre_plan', $data);
$this->load->view('footer');
//I've tried this but it doesn't show validation errors and it misses other views
redirect('prepago/form_pre_plan', 'location');
}
else{
$this->load->view('formsuccess');
$arrPrepago= $this->PrepagoModel->selectPrepago($criteria);
}
Is there any way to redirect to all those views or put them together to just show validation errors?
also i tried to do a view that includes all my views like this one..
Code:
/*prepagoIncluder.php*/
include_once 'header.php';
include_once 'prepago/instrucciones.php';
include_once 'welcome_message';
include_once 'prepago/form_pre_plan';
include_once 'footer.php';
And i'd be able to include just one view in my controller like this:
Code:
/*controller*/
$this->load->view('prepagoIncluder');
But this brings me a lot of problems since it fails to include every file in there. I'd appreciate any help here. Any ideas?