Pass an array as a parameter

2007-03-02 Thread zipman

Hello,

is there any way that I can call a function through url and pass an
array as a parameter?

For example

if I have a function in my test controller
function lala($id)
{
}

I can call it through /tests/lala/id

but if
function foo($array)
{
}

where $array is an array

how can I call a controller function from a view and pass an array as
a parameter?

I have a view where I have a button and I have connected the onclick
event
with calling that function.

Thanks in advance


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Pass an array as a parameter

2007-03-02 Thread zipman

No, that's not what I mean.

I don't want to get the arguments in the function body.
My problem is how to call the function.

If the argument was just a string

I could write



button onclick=update_div('http://localhost/cake/tests/foo/
some_string','main') Click me /button

(update_div is a javascript function to change innerHtml of div wiith
the given id(main above))

but if I have $arr=array('key1'='value1','key2','value2')
and I want to pass that as an argument of foo I cannot use the code
above.


So I am asking if there is any way I can do that.
Even how to explicitly call somehow test_controller-foo($array)
in a view template


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Pass an array as a parameter

2007-03-02 Thread f.


Hi zipman

 but if I have $arr=array('key1'='value1','key2','value2')
 and I want to pass that as an argument of foo I cannot use the code
 above.

Why not do

button onclick=update_div('http://localhost/cake/tests/foo/
some_string?key1=value1key2=value2','main') Click me /button

In fact I have an app with drag and drop article sorting where I POST
the new order of items via AJAX and the url looks like:
/admin/articles/sort/2?sortlist[]=1sortlist[]=11
then the receiving function admin_sort($id) in my articles controller
gets the id (of the category, in the example 2) and inside that
function I have access to my sortlist via:
$this-params['url']['sortlist']
(which turns out to be an array;)

greets,

frank


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---