搜索不在页面上:2使用cakeDC搜索插件

时间:2014-09-25 09:08:44

标签: cakephp cakephp-2.3 cakedc

目前我使用cakeDC搜索插件有一个功能良好的搜索工具。我可以很好地搜索分页。

我的问题是,当我从页面搜索时:2它根本就没有。

这是我的代码:

客户模式

public $actsAs = array('Search.Searchable');
public $filterArgs = array(
    'searchTerm' => array(
        'type' => 'like',
        'field' => array('Customer.name', 'Customer.mobile', 'Customer.address'),
        'filter' => array('type' => 'query', 'method' => 'orConditions')
    )
);

public function orConditions($data = array()) {
    $filter = $data['filter'];
    $cond = array(
        'OR' => array(
            'Customer.name LIKE' => '%' . $filter . '%',
            'Customer.mobile LIKE' => '%' . $filter . '%',
            'Customer.address LIKE' => '%' . $filter . '%',
    ));
    return $cond;
}

CustomersController

 public $components = array('Paginator', 'Session', 'Search.Prg');

 public $presetVars = true;

 public function index() {
    $this->Prg->commonProcess();
    $this->paginate = array();
    $conditions = $this->Customer->parseCriteria($this->passedArgs);
    $this->Customer->recursive = 0;
    $this->paginate = array(
        'limit' => 5,
    );
    $this->set('customers', $this->paginate($this->modelClass, $conditions));
    $this->set('model', $this->modelClass);
}

index.ctp

<?php echo $this->Form->create() ?>
<?php echo $this->Form->input('searchTerm', array('class' => 'form-control','placeholder' => 'search for customer', 'label' => FALSE,'url' => array_merge(array('action' => 'index'), $this->params['pass']))); ?>
<?php echo $this->Form->end() ?>
  

错误:请求的地址&#39; / KPautos / products / index / page:2?searchTerm = j&#39;在这台服务器上找不到。

搜索无法在页面上工作:2 ...

任何帮助都会得到热烈的赞助......谢谢你提前

2 个答案:

答案 0 :(得分:1)

尝试为create form

编写此代码
<?php echo $this->Form->create(null, array('type'=>'get','url' => array('page'=>'1')));?>

而不是

<?php echo $this->Form->create() ?>

答案 1 :(得分:0)

当我从使用CakePHP 2.6的CakeDC插件分页搜索任何页面时,我遇到同样的问题,我理解页面:2或页面:3不存在,所以这就是搜索时标记未找到的原因,所以感谢Sadikhasan,我将表单创建改为:

echo $this->Form->create(null, array('novalidate' => true,'type'=>'get','url' => array('action'=>'index')));

其中index是我用于搜索的主页面。

相关问题