url routing - How to build a Url with multiple query (?) params with CakePHP 3 -
i'm working in redirection autocomplete fields, , i'm doing simple javascript.
i wanted print url without tag, used url builder. i've seen documentation , reviewed source code method in router class see can't understand.
all works right when use url builder code:
<?= $this->url->build(['controller' => 'places', 'action' => 'add', '?' => ['event_id' => $event->id]]) ?> url genetared is:
/places/add?event_id=1 but, when add more params in ? query, & in url, didn't find in docs elimitate special chars filter.
<?= $this->url->build(['controller' => 'places', 'action' => 'add', '?' => ['from' => 'events','id' => $event->id]]) // generates: /places/add?from=events&id=1 // want: /places/add?from=events&id=1 ?> is there option & without &? if put in 1 string, utf codes %5d , those. i'm using url in javascript window.open, i'm not printing in html body.
i see line 597 in http://api.cakephp.org/3.0/source-class-cake.routing.router.html#509-646, don't understand if $url = static::_applyurlfilters($url); code changing something.
thank you!
the url helper ment used generating urls use in markup contexts, therefore being entity encoded using h() function.
in case need plain urls, don't use url helper, router::url() method instead.
use cake\routing\router; router::url([ 'controller' => 'places', 'action' => 'add', '?' => [ 'from' => 'events', 'id' => $event->id ] ]);
Comments
Post a Comment