【发布时间】:2013-04-01 20:44:31
【问题描述】:
我使用的是 Cake 2.3.0。如果我使用POST 提交我的表单,则选定的表单字段会继续,但是如果我使用GET 提交我的表单,所有表单字段都会返回到它们的默认值。
有没有办法让GET 提交像POST 一样工作?
这是我的控制器:
class ListingsController extends AppController {
public function results() {
$conditions = array(
'Listing.Beds >=' => $this->request->query['beds'],
'Listing.ListingStatus >=' => $this->request->query['status'],
);
$this->paginate = array(
'conditions' => $conditions,
);
$this->set('listings', $this->paginate());
}
}
这是我的视图。
echo $this->Form->create(null, array(
'controller' => 'listings',
'action' => 'results',
'type' => 'get'
));
echo $this->Form->input('name');
$beds = array('1' => '1+', '2' => '2+', '3' => '3+', '4' => '4+', '5' => '5+');
echo $this->Form->input('beds', array('options' => $beds));
$status = array('Active' => 'Active', 'Pending' => 'Pending', 'ActivePending' => 'Active and Pending');
echo $this->Form->input('status', array('options' => $status));
echo $this->Form->end('Update');
所以基本上如果我将'type' => 'get' 更改为'type' => 'post' 它就可以正常工作。但我需要能够通过GET 做到这一点。
谢谢
【问题讨论】:
标签: php forms cakephp query-string cakephp-2.3