【发布时间】:2012-12-01 07:59:06
【问题描述】:
我希望通过表单->按钮调用控制器的操作。 我在网页中有以下内容:
- 搜索表单
- 带有 delte 选项作为 postLink 的表
-
2 个按钮应该在点击时调用相同的操作。 我的问题是,当我单击任何按钮时,不会触发发布请求。下面是我的代码: 查看.ctp
echo $this->Form->create('搜索', array( '类型' => '文件', 'url' => 数组( '控制器' => '艺术家', '动作' => '索引', ), )); echo $this->Form->input('name'); echo $this->Form->end(array( '标签' => '搜索艺术家', 'class' => 'btn btn-info 控件' ));
回声 $this->For....echo '' . $this->Form->postlink('', array('action' => 'delete', $row['Artist']['id']), array('confirm' => 'Are you sure?') );echo $this->Form->button('精选', array( '姓名' => '提交', '价值' => '精选', '类型' => '提交', 'url' => 数组( '控制器' => '艺术家', '动作' => '索引', ), ));
echo $this->Form->button('Unfeatured', array( '姓名' => '提交', '价值' => '无特色', '类型' => '提交', 'url' => 数组( '控制器' => '艺术家', '动作' => '索引', ), ));
控制器:
public function isFeatured() {
if ($this->params->data['submit'] == 'Featured') {
//code
} else if($this->params->data['submit'] == 'Unfeatured') {
//code
}
$this->redirect(array('action' => 'index'));
}
我哪里错了?
【问题讨论】:
标签: cakephp view controller action