我需要一些帮助来创建一个带有一个输入框的简单搜索表单。它需要能够将值发送到URL中的控制器,如下所示:
http://mysite.co.uk/properties/results?search=northampton
我想使用cakePHP表单助手,但是你可以包含一个与数据库中的列无关的输入吗?
答案 0 :(得分:3)
从此找到了答案:
///in the view:///
<div class="container">
<a href='#'><div class="search-tab active_search_tab">Property Search</div></a>
<div class="col-md-12 purple search_box">
<?php
echo $this->Form->create('Properties', array('type' => 'get'));
echo $this->Form->input('search', array('between'=>'<label for="search" class="main_search">Search</label><br>','label'=>false));
echo $this->Form->button('Search', array('class'=>'btn btn-success'));
echo $this->Form->end
?>
</div>
</div>
//in the controller//
if(isset($this->params['url']['search'])){
echo 'search text has been found';
}
公平评论burzum