Robert
Robert

Reputation: 293

CakePHP not reading URL parameters correctly

I have a link on a view like this

<a href="playlists/add?video[]=0&amp;video[]=4&amp;video[]=1" id="save_playlist">Save Playlist</a>

However, when it is clicked I am redirected to

/playlists/add/video[]=0&video[]=4&video[]=1

and the output of $this->params['url'] is

Array ( [url] => playlists/add/video[]=0 [video] => Array ( [0] => 4 [1] => 1 ) )

instead of

Array ( [url] => playlists/add/ [video] => Array ( [0] => 0 [1] => 4 [2] => 1 ) )

I can't work out why the firs parameter is always read as part of the url, nor why the leading ? is removed

Upvotes: 0

Views: 634

Answers (1)

Ish
Ish

Reputation: 29606

Try playlists/add?video -> playlists/add/?video

Or just write properly formatted URLs like

$this->Html->link('Save Playlist', array('controller' => 'playlists', 'action' => 'add', 'values[0]'=>3, 'values[1]'=>2, 'values[2]'=>23)); ?>

Upvotes: 1

Related Questions