Welcome Guest, Not a member yet? Register   Sign In
how do i pass an object or array to controller function
#11

[eluser]InsiteFX[/eluser]
Right after checking, you can not pass objects or arrays to a controller!

You could use the sessions or the flash_data.

InsiteFX
#12

[eluser]Drubo[/eluser]
You may also use

echo anchor("controller/method/" . json_encode($things));

from view1 and then in controller2 you may use

json_decode($params);

I think you got your solution.
#13

[eluser]Phil Sturgeon[/eluser]
[quote author="Salvo P" date="1293477427"]implode doesn't really work for me. oh well guess CI just doesn't support it. i'll think of a way around it.

Thanks for the help anyway guys.
salvo[/quote]

Are you mad? PHP doesn't support it Wink

If you want to send an array of data to a controller you have to build a GET string (if you have enabled query string support) or build an associative array of URI segments.

Query strings

Code:
<?php echo anchor('controller/method?'.http_build_query($things), 'Text');

Associative segments

You need to create a URL that has the key names, not just the values (which is what implode does).

Quote:controller/method/key/value/key2/value2

For that you'll have to make a foreach somewhere or avoid using the HTML helpers. Then use $this->uri->uri_to_assoc(3) in your controller.

This is all documented behavior Tongue
#14

[eluser]nuwanda[/eluser]
I may be missing something here, but if you have two views that display data differently, you need two controllers (or methods) to generate that data and pass it to the new view.

So, controller 1 passes data to view 1

User clicks a link in view 1 to display the data differently

That link calls a new controller method that then calls view 2

No?
#15

[eluser]Phil Sturgeon[/eluser]
Of course.




Theme © iAndrew 2016 - Forum software by © MyBB