我希望通过表单->按钮调用控制器的操作。我在网页中有以下内容:
- 搜索表格
- 带有 delte 选项的表作为 postLink
2 个按钮应该调用相同的操作 onclick。我的问题是,当我单击任何按钮时,不会触发发布请求。下面是我的代码:view.ctp
echo $this->Form->create('Search', array('type' => 'file', 'url' => array('controller' => 'artists', 'action' => 'index', ), )); echo $this->Form->input('name'); echo $this->Form->end(array( 'label' => 'Search Artist', 'class' => 'btn btn-info controls' ));
回声 $this->For....echo '' . $this->Form->postlink('', array('action' => 'delete', $row['Artist']['id']), array('confirm' => 'Are you sure?') );
echo $this->Form->button('Featured', array('name' => 'submit', 'value' => 'Featured', 'type' => 'submit', 'url' => array( '控制器' => '艺术家', '动作' => '索引', ), ));
echo $this->Form->button('Unfeatured', array('name' => 'submit', 'value' => 'Unfeatured', 'type' => 'submit', 'url' => array( '控制器' => '艺术家', '动作' => '索引', ), ));
控制器:
public function isFeatured() {
if ($this->params->data['submit'] == 'Featured') {
//code
} else if($this->params->data['submit'] == 'Unfeatured') {
//code
}
$this->redirect(array('action' => 'index'));
}
我哪里错了?