0
我有方法的簡單的搜索得到這樣的:搜索表單式的get(CakePHP的3)
<?= $this->Form->create('Search',['type'=>'get']) ?>
<fieldset>
<legend><?= __('Search') ?></legend>
<?php
echo $this->Form->input('id');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
在我的routes.php文件我有路由器控制:
$routes->connect(
'/test/search/:id',
array('controller' => 'test', 'action' => 'search'), // Local à ser redirecionado
array(
'pass' => array('id'),
'id' => '[0-9]+'
));
爲了控制我的網址如:/ test/search /:search_id。
問題是我的表單發送請求到/ test/search?id =:search_id。 我需要做什麼,以形成發送到正確的網址:/ test/search /:search_id?
謝謝。
'你controller' beforeFilter影響該控制器中的所有操作 - 最好將該檢查放入搜索功能中。還要注意,這可以用js解決(onsubmit - > document.location = x; return false)。 – AD7six