1

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

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.

E.g.:

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

1 Answer 1

1

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

if ($someFieldIsPresentCheckHere) {
    $this->Model->filterArgs['someThing'] = [ /* settings go here */ ];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.