Welcome Guest, Not a member yet? Register   Sign In
How to return data from a callback function? (form validation)
#1

[eluser]stormbytes[/eluser]
Pretty straight-forward question here:

I'm trying to return an array from a callback function. How would I do that?

I tried saving the array as flashdata, but for some reason it gets purged when the next model is called (in the same stack). I thought flashdata is preserved until the following http-request (page)?

Well anyhow, if there's a way to simply pass the array from the callback to 'somewhere', that would make things simpler altogether.

Cheers!
#2

[eluser]LuckyFella73[/eluser]
Your title says that you are trying to return an array from
a callback function called while using the form validation class.
I would say you can only return true or false in that case.

Maybe you meant just processing the data in the callback before
returning true/ false? I would try to store the values in a session then.
Should work as well to store the data like
Code:
$this->my_data = array(...);
What is better in your case is hard to say without knowing what you
are going to do exactly.
#3

[eluser]stormbytes[/eluser]
Exactly correct. I'm trying to return a value (var, array, etc) from the validation callback function. I'm wondering if this is possible? The user guide seems to imply that it is.

I've already tried using flashdata (session) to pass my array to the validation function (controller method that receives the validated data) but for some reason the flashdata is purged as soon as another model is called. Weird.. It's supposed to last through the http request.




Theme © iAndrew 2016 - Forum software by © MyBB