Welcome Guest, Not a member yet? Register   Sign In
callback return result
#1

[eluser]PV-Patrick[/eluser]
On validation, using a callback method... Is it possible to return 2 results? I am wanting to use a callback to return both data and boolean.... since I think the validation class works off boolean only. Any suggestions?

EDIT: Can I return anything I want with the callback for a TRUE instance? Let's say instead of returning TRUE, I return an array?

I'll refine what I am trying to do a little...

I want to validate a form, in doing so call a callback to validate certain items and if it passes, I want to return data from that validation function to the SUCCESS portion of the validation process. Is this possible?

Basically....

if($this->validation->run() == FALSE) {
} else {
Use return data from callback_function
}
#2

[eluser]Ebot Ndip-Agbor[/eluser]
Callback methods return boolean as mentioned. Storing the array in a session as flash data might do the trick.
#3

[eluser]PV-Patrick[/eluser]
Alright, thanks for the info! I think the flash data might not be the right solution from what I can see because it limits it to 1 request and then clears. If the form validation fails again, that data is gone unless I preserve it?

So let's say I want to keep an auth_code handy for the user for x amount of tries at form validation, would regular session data be the route?
#4

[eluser]Ebot Ndip-Agbor[/eluser]
Yes this can be done for an x amount of tries using session.
Use $this->session->keep_flashdata().Like so
Code:
//code goes here
if($this->validation->run() == FALSE) {
$this->session->keep_flashdata('your_array');
} else {
}
#5

[eluser]PV-Patrick[/eluser]
Thank you very much for your help Ebot!! I think I got it all working how I want now, thanks again!
#6

[eluser]Ebot Ndip-Agbor[/eluser]
Glad I could help ;-)




Theme © iAndrew 2016 - Forum software by © MyBB