Welcome Guest, Not a member yet? Register   Sign In
Form validation with redirect
#3

(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!
Reply


Messages In This Thread
Form validation with redirect - by msheath - 10-26-2015, 04:42 AM
RE: Form validation with redirect - by Martin7483 - 10-26-2015, 05:34 AM
RE: Form validation with redirect - by msheath - 10-26-2015, 07:26 AM
RE: Form validation with redirect - by Martin7483 - 10-26-2015, 07:44 AM
RE: Form validation with redirect - by msheath - 10-26-2015, 08:09 AM
RE: Form validation with redirect - by msheath - 10-28-2015, 02:39 AM
RE: Form validation with redirect - by Narf - 10-27-2015, 03:42 AM
RE: Form validation with redirect - by msheath - 10-28-2015, 02:54 AM
RE: Form validation with redirect - by Narf - 10-28-2015, 04:21 AM
RE: Form validation with redirect - by msheath - 10-28-2015, 04:50 AM
RE: Form validation with redirect - by Martin7483 - 10-27-2015, 12:16 PM
RE: Form validation with redirect - by msheath - 10-28-2015, 02:15 AM
RE: Form validation with redirect - by mwhitney - 10-27-2015, 12:29 PM
RE: Form validation with redirect - by Martin7483 - 10-28-2015, 02:41 AM
RE: Form validation with redirect - by Martin7483 - 10-28-2015, 05:00 AM
RE: Form validation with redirect - by msheath - 10-28-2015, 05:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB