Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query parameter value filter containing period in string name is not running #292

Closed
jadelbe418 opened this issue Oct 7, 2020 · 4 comments

Comments

@jadelbe418
Copy link
Contributor

I am currently using example similar to the first 2 listed here to grab search filters:

class ExampleCollection extends Search\Model\Filter\FilterCollection
{
   public function initialize()
    { 
       // 1. Filters when present
       $this->value('name', [
            'multiValue' => true,
            'multiValueSeparator' => ',',
            'mode' => 'AND',
            'field' => 'name',
        ]);

       // 2. Does not filter when present
       $this->value('example.type_id', [
            'multiValue' => true,
            'multiValueSeparator' => ',',
            'mode' => 'AND',
            'field' => 'Example.type_id',
        ]);
 
       // 3. Filters when present
       $this->value('type_id', [
            'multiValue' => true,
            'multiValueSeparator' => ',',
            'mode' => 'AND',
            'field' => 'Example.type_id',
        ]);
   }
}

The first value call of value your works and the second does not. For some reason FreidndsOfCake/Search is not recognizing uri parameters containing a period, like 'example.type_id'.

Is this a bug or by design? Or am I missing some piece of configuration needed to do this?

@ADmad
Copy link
Member

ADmad commented Oct 8, 2020

Using dot separated names for the search fields is not supported. There's no need for your search form names to exactly match your db fields and/or associations. Just rename the field to for e.g. example_type.

@ADmad ADmad closed this as completed Oct 8, 2020
@jadelbe418
Copy link
Contributor Author

jadelbe418 commented Oct 8, 2020

Well it breaks the conventions used in my application to not include the dot. Also there is no mention of certain characters being off limits in the docs.

But I can work around it if that is what we need to do. Thanks.

@ADmad
Copy link
Member

ADmad commented Oct 8, 2020

Also there is no mention of certain characters being off limits in the docs.

There's no special mention as it's default Cake behavior that a dot in field name generates an array. It's not something special in the plugin. example.type_id will give you HTML input with name example[type_id].

@jadelbe418
Copy link
Contributor Author

That makes sense. I did not know that about Cake. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants