(10-26-2015, 05:34 AM)Martin7483 Wrote: I assume you are posting to the same page where the form is loaded and validated. In that case you could add the #anchor to the post URL. Using flashdata would require more conditionals
The form is on its own page but the validation is done, as normal, in the controller in what I have called the 'send' function. Having set the validation rules I do:
Code:
if($this->form_validation->run() == false)
{
redirect('site/home#anchor');
}
and that takes me back to the page and autoscrolls to the anchor (ie the form) but the validation errors are not passed. If instead I do
Code:
if($this->form_validation->run() == false)
{
$this->home;
}
I get to the page and validation errors are passed but I land at the top of the page instead of scrolling down to the form. If I do:
Code:
if($this->form_validation->run() == false)
{
$this->home#anchor');
}
There is a 'not found' error because there is no page with a url of .../home#anchor.php
So I'm stuck!