Comments (12)
Some filters can take multiple fields and hence an array while some only take a single once hence a string.
from search.
@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.
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.
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.
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.
Besides that I think it should throw an Exception as well if an invalid arg is passed.
from search.
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.
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.
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.
@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.
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.
@inoas sure. But still I'm not sure where so check in the source code to find what config is actually supported.
search/src/Model/Filter/Base.php
Line 59 in dd370c8
from search.
Related Issues (20)
- Additional search data from request to manager HOT 4
- Help on installation.
- Any way to get the matched text of a particular field?
- Query parameter value filter containing period in string name is not running HOT 4
- Bake filter collections? HOT 2
- warning with bake in cake42 HOT 4
- Conflict with Migration ? HOT 2
- 3.9 not working as usual HOT 8
- Can't search in associated Model HOT 1
- SearchComponent conflict with DisableGenericTables HOT 4
- Search resetUrl function HOT 6
- Bug/inconvenience when baking FilterCollections HOT 4
- Passing an integer value to the search query HOT 2
- German umlauts not recognized HOT 4
- Complex Searches (question / request) HOT 3
- BC issue HOT 15
- Reset doesn't work WA's solution to keep search filters HOT 2
- belongsToMany Search not Working HOT 5
- 5.x: Search exception HOT 5
- Casting needed for Finder filter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from search.