Giter Club home page Giter Club logo

Comments (12)

ADmad avatar ADmad commented on June 15, 2024 1

Some filters can take multiple fields and hence an array while some only take a single once hence a string.

from search.

powtac avatar powtac commented on June 15, 2024 1

@inoas
->add('active', 'Search.Boolean') does work.
->add('active', 'Search.Boolean', ['field' => ['active']]) does not work.

As @ADmad confirms, the method signature for the value of "field" is different for some filters. IMHO this is unclear from the docs. Probably they should be written with ucfirst() in the docs as well.

from search.

dereuromark avatar dereuromark commented on June 15, 2024 1

One should think that with such a large community base those would be way better documented than any of those single-person ones out there.. ;) well well

from search.

burzum avatar burzum commented on June 15, 2024

Define "not to work" and show your code. :)

The filter itself is well covered with tests -> https://github.com/FriendsOfCake/search/blob/master/tests/TestCase/Model/Filter/BooleanTest.php

from search.

powtac avatar powtac commented on June 15, 2024

Ok, I figured it out:

            ->add('success', 'Search.Boolean', [
                'mode'          => 'and',
                'field'         => 'success' // This works! This not: 'field' => ['success']
            ])   

field can not be an array in case of Boolean! Seems like a documentation issue.

from search.

burzum avatar burzum commented on June 15, 2024

Besides that I think it should throw an Exception as well if an invalid arg is passed.

from search.

inoas avatar inoas commented on June 15, 2024

1. Can you confirm that:

->add('active', 'Search.Boolean')

... doesn't work (active must be tinyint(1) / boolean)?

2. Can you give it a try and change:

https://github.com/FriendsOfCake/search/blob/master/src/Model/Filter/Boolean.php#L37
from:

$this->query()->andWhere([$this->field() => $bool]);

to:

foreach ((array) $this->field() as $field) {
    $this->query()->andWhere([$field => $bool]);
}

If it works I will see if the tests are okay with it and create a PR.

p.s.: @burzum @jippi is field meant to take an array for all filters?

from search.

burzum avatar burzum commented on June 15, 2024

I agree with @powtac that the API is not very intuitive and his example is pretty confusing. I wouldn't expect this behavior, it just doesn't make sense if you looked at the other filters before.

Filters should fail hard (Exception) if you don't configure them right.

from search.

ADmad avatar ADmad commented on June 15, 2024

In general most FOC plugins are a bit lacking when it comes to documentation. We need the community's help to improve that 😄

from search.

burzum avatar burzum commented on June 15, 2024

@dereuromark well, forget it. :) My personal experience is that 99% of the people just take and a fraction of them is even as bold to demand things to be done ASAP and for free. Neither for the CakeDC nor for my own plugins I've ever seen much community contribution, especially when it comes to documentation.

from search.

inoas avatar inoas commented on June 15, 2024

I don't have a problem adding array support. It should not be expected to do magic like being able to do AND OR XOR etc... but it would be able to simply check two fields (Edit: both to be true xor false). That would also get it in line if you supplied an array. However I find the hashKey "field" to point at singular.

So in case you want me to act @ADmad let me know, else I will shut-up.

@powtac Would you care to create a PR to the docs to explain that it only takes a single string?

from search.

powtac avatar powtac commented on June 15, 2024

@inoas sure. But still I'm not sure where so check in the source code to find what config is actually supported.

$defaults = [
does not tell much about array/not array.

from search.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.