モデル
<?php
App::uses('AppModel','Model');
class Bottom extends AppModel{
public $belongsTo = array('Region','Sregion','Money','Shokushu','Koyou');
public $order = array('Bottom.id DESC');
public $actsAs = array('Search.Searchable');
public $filterArgs = array(
'keyword' => array('type' => 'like','field' => array('Bottom.title','Bottom.comment','Bottom.username','Bottom.email'), 'connectorAnd' => '+', 'connectorOr' => ','),
'koyou_id' => array('type' => 'value','field' => array('Bottom.koyou_id')),
'money_id' => array('type' => 'value','field' => array('Bottom.money_id')),
'region_id' => array('type' => 'value','field' => array('Bottom.region_id')),
'sregion_id' => array('type' => 'value','field' => array('Bottom.sregion_id')),
'shokushu_id' => array('type' => 'value','field' => array('Bottom.shokushu_id')),
);
}
コントローラ
public function find() {
$this->Bottom->recursive = 0;
$this->Prg->commonProcess();
$this->paginate = array(
'conditions' => $this->Bottom->parseCriteria($this->passedArgs),
);
$this->set('data', $this->paginate());
$this->set('list1',$this->Bottom->Koyou->find('list',array('fields'=>array('id','koyou_name'))));
$this->set('list2',$this->Bottom->Money->find('list',array('fields'=>array('id','money_cate'))));
$this->set('list3',$this->Bottom->Region->find('list',array('fields'=>array('id','region_name'))));
$this->set('list4',$this->Bottom->Sregion->find('list',array('fields'=>array('id','sregion_name'))));
$this->set('list5',$this->Bottom->Shokushu->find('list',array('fields'=>array('id','shokushu_name'))));
}
ヴュー
<h1>検索機能</h1>
<div class="row-fluid">
<div class="span9">
<?= $this->Form->create('Bottom');?>
<?= $this->Form->input('keyword',array('type' => 'text','label' => 'キーワード検索'));?>
<?= $this->Form->input('koyou_id',array('type' => 'select','options' => $list1,'empty' => true,'label' => '雇用形態'));?>
<?= $this->Form->input('money_id',array('type' => 'select','options' => $list2,'empty' => true,'label' => '時給から'));?>
<?= $this->Form->input('region_id',array('type' => 'select','options' => $list3,'empty' => true,'label' => '都道府県'));?>
<?= $this->Form->input('sregion_id',array('type' => 'select','options' => $list4,'empty' => true,'label' => '小地区'));?>
<?= $this->Form->input('shokushu_id',array('type' => 'select','options' => $list5,'empty' => true,'label' => '職種から'));?>
<?= $this->Form->end('送信');?>
<table>
<?php if(isset($data)) :?>
<?php foreach($data as $post):?>
<tr><td><?= $this->Html->link('id',array('controller' => 'bottoms','action' => 'view',$post['Bottom']['id']));?></td></tr>
<tr><td><?= $post['Bottom']['username'];?></td>
<td><?= $post['Bottom']['title'];?></td>
<td><?= $post['Bottom']['email'];?></td>
<td><?= $post['Bottom']['comment'];?></td>
<td><?= $post['Region']['region_name'];?></td>
<td><?= $post['Sregion']['sregion_name'];?></td>
<td><?= $post['Money']['money_cate'];?></td>
<td><?= $post['Shokushu']['shokushu_name'];?></td>
</tr>
<?php endforeach;?>
<?php endif;?>
</table>
</div>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。