【问题标题】:Dynamically create the $filterArgs array in CakePHP在 CakePHP 中动态创建 $filterArgs 数组
【发布时间】:2015-07-22 11:01:00
【问题描述】:

使用search插件时是否可以在CakePHP中动态创建$filterArgs数组?

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

例如:

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

【问题讨论】:

    标签: php cakephp search frameworks


    【解决方案1】:

    只需根据需要有条件地将它们添加到 filterArgs 数组中。

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

    【讨论】:

    • 谢谢 :) 正是我需要的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-02
    • 2012-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    相关资源
    最近更新 更多