Welcome Guest, Not a member yet? Register   Sign In
Flash Data Without Redirect
#5

[eluser]boltsabre[/eluser]
In a simplistic overview of how userdata/flashdata and the global $_POST array works is:

- To display a newly created userdata/flashdata variable you have to use redirect().
- If you do this, your $_POST array gets emptied because well... there is nothing posted anymore, you've simple redirected them to a new script, which executes, thus the user hasn't had a chance to populate anything into $_POST.

So what you're trying to do, which is set & display a flashdata variable AND preserve the data inside $_POST, are at conflict with the above 2 points and cannot be done without some trickery.

The easiest way, and the path with the least resistance or chance of bugs, or data being lost, is to instead of using flashdata for this "Student Does Not Exist" validation check is to create a validation callback function.

I assume you are currently doing something like this???
- User submits form
- You validate it
- If errors are found you redisplay the form, with the users input still displayed in the inputs, and display the validation messages. Else
- Validation passed, now you do your model call to check if the student exists. If they don't exist you're trying to display the flash message with redirect() AND re-populate the form the the previous user input.

If so, don't... use a callback function. It's in the link I first posted. Are you checking the email address for if the student exists? If so, attach the callback to the email validation rules in your controller.


Messages In This Thread
Flash Data Without Redirect - by El Forum - 03-27-2013, 06:51 AM
Flash Data Without Redirect - by El Forum - 03-27-2013, 07:29 AM
Flash Data Without Redirect - by El Forum - 03-27-2013, 07:32 AM
Flash Data Without Redirect - by El Forum - 03-27-2013, 09:17 AM
Flash Data Without Redirect - by El Forum - 03-27-2013, 09:28 AM
Flash Data Without Redirect - by El Forum - 03-27-2013, 09:31 AM
Flash Data Without Redirect - by El Forum - 03-27-2013, 11:21 AM
Flash Data Without Redirect - by El Forum - 03-27-2013, 11:25 AM
Flash Data Without Redirect - by El Forum - 03-27-2013, 01:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB