2
votes

I'm very new to Cakephp and am struggling with this.

I have a loop in my view and this makes it a good place to create an array I need. I could have anywhere from 5 to 200 string values. My problem is I need to use this array in my controller. Below is the code I use for a link. I pass a number to the function createtiles in my controller. I read that I cannot pass an array like this?? Is there a way I can use the array values from my view in my controller?

echo $this->Html->link(' CREATE PAGES TO PRINT ', array('action' => 'createtiles', $post['Grv']['tran_no']));

1

1 Answers

2
votes

You can't use the array directly in your link, even as a param of comma separated values as you're very likely to exceed the GET limit for parameter length.

But, you could put your array into hidden form fields and use Javascript to POST "with" your values, or set your values directly in a params object to be POSTed by the Ajax call.

Otherwise I'd seriously look into ways to do your array manipulation in the controller or model, passing large sets of data from the browser isn't generally a good idea and best avoided if possible.