Reputation: 27364
I am using cakephp 1.3
and i want to search a record which contain / in string.
i have passed parameter as below.
Search params are as below.
Array
(
[controller] => indents
[action] => admin_index
[named] => Array
(
[pr_no_data] => pr
)
[pass] => Array
(
[0] => no
[1] => dip
[2] => 002
)
[prefix] => admin
[admin] => 1
[plugin] =>
[form] => Array
(
)
[url] => Array
(
[url] => admin/indents/index/pr_no_data:pr/no/dip/002
)
[isAjax] =>
)
as you all can see my url params contain admin/indents/index/pr_no_data:pr/no/dip/002
and now i want to search pr_no as defined in url.
How can i do this.?
because search for / record passing values as passed parameter.
Please help me.
Thanks a lot.
Upvotes: 1
Views: 565
Reputation: 11574
As you can see in your array, CakePHP sees part of the data as passed parameters. In the pr_no_data
named variable, you see it references pr
as it's value.
[named] => Array
(
[pr_no_data] => pr
)
However, the remaining character string in the data is recognized as passed parameters because of the slashes. So it is reading them as part of the URL, not the pr_no_data
variable.
[pass] => Array
(
[0] => no
[1] => dip
[2] => 002
)
What you need to look at is how you generate that variable before it is added to the URL. Perhaps you can change it to a pipe | separated list or a comma , separated list so it does not interfere with the URL and confuse cakephp.
pr|no|dip|002
pr,no,dip,002
Once cakephp receives the data, you can then convert them back to slashes if needed:
$passed = preg_replace('/,/', '/', $this->params['named']['pr_no_data']);
Upvotes: 1
Reputation: 54801
Try to encode the named parameter value using urlencode.
The URL should be
admin/indents/index/pr_no_data:pr%2Fno%2Fdip%2F002
If you create the URL using the Html helper, then CakePHP should encode the value for you.
echo $this->Html->url(array(
'prefix'=>'admin',
'controller'=>'indents',
'action'=>'index',
'pr_no_data'=>'pr/no/dip/002'
));
Upvotes: 0