我有了这个观点
?php echo $this->Form->create('Search', array('id' => 'Search', 'url' => array('controller' => 'mycontroller', 'action' => 'index'))); ?>
<?php echo $this->Form->input('usuario_id', array('label' => __('Vendedores', true), 'options' => $vendedores, 'empty' => true)); ?>
<?php echo $this->Form->input('cliente_id', array('label' => __('Cliente', true), 'options' => $clientes, 'empty' => true)); ?>
<?php echo $this->Location->estados(); ?>
<?php echo $this->Location->municipios(); ?>
<?php echo $this->Location->bairros(); ?>
<?php echo $this->Form->input('equipe_id', array('label' => __('Equipe', true), 'options' => $equipe, 'empty' => true)); ?>
<?php echo $this->Form->input('veiculo_id', array('label' => __('Modelo', true), 'options' => $veiculos, 'empty' => true)); ?>
<?php echo $this->Form->input('status', array('label' => __('Status', true), 'options' => $status, 'empty' => true,'multiple' => true )); ?>
<?php echo $this->Utils->data('date_from', array('input' => array('label' => 'De'))); ?>
<?php echo $this->Utils->data('date_to', array('input' => array('label' => 'a'))); ?>
<?php echo $this->Form->hidden('Search.search'); ?>
<?php echo $this->Form->end('Buscar'); ?>
和我的控制器分页条件如下
if(!empty($this->data['Search']['myvar_id'];)) $this->paginate['conditions']['myModel.myvar_id'] = $this->data['Search']['myvar_id'];
所有搜索字段都正常工作,在#1页面中,没关系,但是当我分页到#2页面时,会清除这些值。 如你所见,我在表格上使用post方法, 所以使用这个场景,我怎么能确定当我分页时值不会丢失?
先谢谢!
答案 0 :(得分:-1)
这是一件很简单的事情
if(isset($this->data[<some variable>])){
if(!empty($this->data[<some variable>])){
$keyword = trim($this->data[<some variable>]);
$this->redirect('/controller/action/keyword:'.$keyword.));
}
}elseif(isset($this->params['named']['keyword'])){
if(!empty($this->params['named']['keyword'])){
$keyword =$this->params['named']['keyword'];
$this->paginate['conditions'] = array("ModelName.Fieldname LIKE" => "%$keyword%");
}
}
这是一种最好和最简单的方式4 maindaing分页值,你可以拥有更多
比较在一个关键词中,并且可以在条件后缀中使用。