开发者

pass an array from the view to the controller (Cakephp)

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开发者_JS百科 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']));


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜