Welcome Guest, Not a member yet? Register   Sign In
Form Validation
#1

[eluser]ShoeLace1291[/eluser]
I have a problem with my forms. I'm making an admin panel that has a form on one page. In the first form, all the user does is enter the number of rows he would like to insert in the next form. So, if a user enters the number 5 in the first form, the next form will loop through 5 different form arrays.

The forms are in the same controller, but in different functions. The problem is that when the user enters the number and submits the form, it takes it to the appropriate page, however, the validation errors are already displayed.

Any ideas?
#2

[eluser]Dennis Rasmussen[/eluser]
The Form_validation library is simply looking for POST data, so before you run the form validation, check to see if the user is coming from the first form or the form on the second page.

Code:
$submit = $this->input->post('field_from_second_page', false);
if ($submit)
{
  // This is the second page with the array and everything, let's validate and do stuff...
}
else
{
  // This is the first time we see the second page, don't show any errors.
}

Something like that.
Hope that makes sense.
#3

[eluser]Dennis Rasmussen[/eluser]
The Form_validation library is simply looking for POST data, so before you run the form validation, check to see if the user is coming from the first form or the form on the second page.

Code:
$submit = $this->input->post('field_from_second_page', false);
if ($submit)
{
  // This is the second page with the array and everything, let's validate and do stuff...
}
else
{
  // This is the first time we see the second page, don't show any errors.
}

Something like that.
Hope that makes sense.
#4

[eluser]ShoeLace1291[/eluser]
It makes sense, but regardless of whether or not it's coming from the first page, I still need to validate the information on the second page once that form is submitted.
#5

[eluser]ShoeLace1291[/eluser]
I figured it out. I changed the action of the form to the same page. Then in the else statement of the form_validation->run() function, I created flashdata and redirected the page.




Theme © iAndrew 2016 - Forum software by © MyBB