我是cakephp的初学者,我想用"搜索框","选择"和#34; Radio Buttons",我发现了一些插件,但是当我尝试实现它时我迷路了,我希望你可以帮我一些插件和教程。
修改
形式:
<div>
<?= $this->Form->create($multimedia, array('controller' => 'multimedia', 'action' => 'search', 'type' => 'get')); ?>
<?= $this->Form->input('category_id', ['class' => 'electdown',
'label' => false,
'empty' => 'Categories',
'options' => $categories
]); ?>
<?= $this->Form->input('buscador', array('placeholder' => 'Search...', 'label' => false)); ?>
<?= $this->Form->submit('login_BDP_logo.png', array('type' => 'button', 'id' => 'buscar', 'div' => false)); ?>
<?= $this->Form->end(); ?>
</div>
&#13;
MultimediaController:
public function search(){
$multimedia = array();
if (!empty($this->params['Multimedia'])) {
$query = $this->params['query']['buscador'];
$query = $this->params['query']['category_id'];
$conditions = array(
'conditions' => array(
'or' => array(
'Multimedia.title LIKE' => "%$query%",
'Multimedia.description LIKE' => "%$query%",
'Multimedia.mime_type LIKE' => "%$query%",
'Multimedia.filename LIKE' => "%$query%",
'Multimedia.url LIKE' => "%$query%",
'Multimedia.language_id LIKE' => "%$query%",
'Multimedia.category_id LIKE' => "%category_id%",
'Multimedia.created_by LIKE' => "%$query%"
)
)
);
$multimedia = $this->Multimedia->find('all', $conditions);
}
$this->set('negocios', $negocios);
debug($this->params);
}
&#13;
更新 这个:
public function search(){
$multimedia = array();
if (!empty($this->request->query)) {
$query = $this->request->query['search'];
$category_id = $this->request->query['category_id'];
//$language_id = $this->request->query['language_id'];
$conditions = array(
'conditions' => array(
'and' => array()));
if ($query) $conditions['conditions']['and']['Multimedia.title LIKE'] = "%$query%";
if ($category_id) $conditions['conditions']['and']['Multimedia.category_id'] = $category_id ;
//if ($language_id) $conditions['conditions']['and']['Multimedia.language_id'] = $language_id ;
/*
'Multimedia.title LIKE' => "%$query%",
// 'Multimedia.description LIKE' => "%$query%",
// 'Multimedia.mime_type LIKE' => "%$query%",
// 'Multimedia.filename LIKE' => "%$query%",
// 'Multimedia.url LIKE' => "%$query%",
// 'Multimedia.language_id LIKE' => "%$query%",
'Multimedia.category_id' => $category_id
// 'Multimedia.created_by LIKE' => "%$query%"
)
)
); */
$multimedia = $this->Multimedia->find('all', $conditions);
$this->set('multimedia', $multimedia);
$languages = $this->Multimedia->Languages->find('list', ['limit' => 200]);
$categories = $this->Multimedia->Categories->find('list', ['limit' => 200]);
$users = $this->Multimedia->Users->find('list', ['limit' => 200]);
$this->set(compact('multimedia', 'languages', 'categories', 'users'));
$this->set('_serialize', ['multimedia']);
}
}