在CakePHP中动态创建$ filterArgs数组 [英] Dynamically create the $filterArgs array in CakePHP

查看:198
本文介绍了在CakePHP中动态创建$ filterArgs数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 $ filterArgs nofollow>搜索插件?

Is it possible to dynamically create the $filterArgs array in CakePHP when using the search plugin?

我的客户可以创建自己的输入字段(特定于客户),我想让所有这些字段都可搜索。但为此,我必须在$ filterArgs 数组中映射它们。

My customers are able to create their own input fields (customer specific) and I want to make all of them searchable. But for this I have to map them in the $filterArgs array.

例如:

public $filterArgs = array(
    'input_filter' => array(
        'type' => 'subquery',
        'method' => 'findCustomerCustomFieldsByText',
        'field' => 'Customer.id',
        'encode' => true
    )
);


推荐答案

只要根据需要有条件地添加filterArgs数组

Just add them conditionally as you need to the filterArgs array.

if ($someFieldIsPresentCheckHere) {
    $this->Model->filterArgs['someThing'] = [ /* settings go here */ ];
}

这篇关于在CakePHP中动态创建$ filterArgs数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆