如何在表单发送请求后删除URL中的控制器名称?

时间:2011-09-20 08:15:47

标签: .htaccess cakephp cakephp-1.3

我的表格发出后,我得到:

http://... /param1/param2/CONTROLLER-NAME

如何摆脱网址的最后一部分 - CONTROLLER-NAME?

标准表单视图:

        echo $this->Form->create('*',
        array('url' => array('controller' => '*', 'action' => '*')           
        ));
        echo $this->Form->input('*', array('div' => false, 'empty' => true));
        echo $this->Form->submit(__('Search', true), array('div' => false));
        echo $this->Form->end();

1 个答案:

答案 0 :(得分:2)

为什么在表单中使用'*'

通常,您的表单应如下所示:

    echo $this->Form->create('Search', // model name, even if it doesn't really exists
        array('url' => array('controller' => 'searches', 'action' => 'index')
    ));
    echo $this->Form->input('search', array('div' => false, 'empty' => true));
    echo $this->Form->submit(__('Search', true), array('div' => false));
    echo $this->Form->end();

正常情况下,蛋糕正在创建这样的网址,通常生成的网址格式为/controller/action/params,如果你想

,你可以使用routes.php重新定义

希望这有帮助