[eluser]WebbHelp[/eluser]
Hi!
Sorry, it feels like I am posting thread after thread... but the positive thing is that I am learning a lot hehe
I hope I will pay you back later when I can more, and can help other people on the forum.
I am interesting in validation_erros(); I have used it, and I have got it to work.
But my question is more like:
If I, with my form, use the action to a function with the name submitgeneral, then on the controller page, and the submitgeneral function, I check for some errors, If there are any errors, the page will be shown again and show the errors.
How would I do then, in the best way I mean, this time i did like this:
In the submitgeneral function, I checked for errors, if there were any errors, I "called" a function generalsettings() that loaded the page with... I will show with some code:
Code:
public function generalsettings()
{
$data['menus'] = $this->db->query("SELECT id,menu FROM pages ORDER BY id ASC");
$this->load->view('admin/general', $data);
}
function submitgeneral()
{
//Include the form_validation class
$this->load->library('form_validation');
//Check if the name field isn't empty(ignore space), the minimum length(2) and it clean the input from XSS attacks.
$this->form_validation->set_rules('name', 'Namn','trim|required|xss_clean');
//Setting a own rule in function menucheck, the function checks if the menuchoice exists.
$this->form_validation->set_rules('standard', 'Standard','callback_menucheck');
// If form doesn't validate the rules, this is also false when the admin visit the page and then
if ($this->form_validation->run() == false)
{
$this->generalsettings();
}
else
{
echo 'TJOHO';
}
}
}
You see, I call the function generalsettings if there are any errors and that function is loading the formular page.
Is that a good way to do it?
How should I do?
because if I use redirect(); I lose my validation_errors();
Thanks you //WebbHelp
If you don't understand my question just write som "???" and I try to explane it in another way