後,我用蛋糕2.3.0。如果我使用POST
提交我的形式,選定的表單域結轉但是如果我使用GET
提交我的表單,所有的表單字段恢復爲默認值。CakePHP的:「GET」形式不自動填充表單字段提交
有沒有辦法使GET
提交工作像POST
那樣工作?
這裏是我的contorller:
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
做到這一點。
感謝
我試圖在控制器的幾個地方添加這個,但似乎沒有工作。 – bigmike7801