Code Monkey home page Code Monkey logo

Comments (11)

cedric-g avatar cedric-g commented on July 21, 2024

Hi, for the filter_choice it's a forgetting from us, maybe we should check if the value we get is a collection or a single value. But the option should work with the filter_entity except if the relation is a many-to-many, in this case you will have to override the filter by using the apply_filter options

from lexikformfilterbundle.

gaetan-petit avatar gaetan-petit commented on July 21, 2024

@cedric-g : it doesn't seems to work with filter_entity :

Catchable Fatal Error: Argument 1 passed to My\Entity\Class::getProperty() must be an instance of My\Entity\Class, instance of Doctrine\Common\Collections\ArrayCollection given, called in PropertyAccessor.php on line 438

Form code:

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('property', 'filter_entity', array(
            'class' => 'MyBundle:MyEntity',
            'expanded' => TRUE,
            'multiple' =>  TRUE,
        ));
    }

from lexikformfilterbundle.

rvanlaak avatar rvanlaak commented on July 21, 2024

That is what Cedric said with its previous comment. You can make use of the 'apply_filter' option, look at the link for an example.

https://github.com/lexik/LexikFormFilterBundle/blob/master/Resources/doc/index.md#a-with-the-apply_filter-option

You should iterate over the results, in order to add it to the QueryBuilder

from lexikformfilterbundle.

gaetan-petit avatar gaetan-petit commented on July 21, 2024

@rvanlaak @cedric-g : I'm sorry but I have read the doc several times and I have absolutely no clue of what I should do with apply_filter option to fix this.

from lexikformfilterbundle.

cedric-g avatar cedric-g commented on July 21, 2024

@gaetan-petit do you use a data_class in your type ?
If yes I suppose the field on which you use filter_entity is a single relation, but when you set multiple to true this mean the type will handle a collection (this is the behavior of the entity type). So when the form is submitted and it try to call setProperty() it will pass a collection instead of a single entity.
Just don't defined any data_class and it should work.

from lexikformfilterbundle.

gaetan-petit avatar gaetan-petit commented on July 21, 2024

@cedric-g Thanks for the answer but something is still wrong.

When multiple option are selected the query is not correct, and returns no results:

AND t1_.status_id IN ('43,44,45') 

Instead of:

AND t1_.status_id IN (43,44,45) 

I'am trying to spot where is the faulty code, but I bet you will be faster than me 😉

from lexikformfilterbundle.

cedric-g avatar cedric-g commented on July 21, 2024

@gaetan-petit Which version of the bundle are you using ?

from lexikformfilterbundle.

gaetan-petit avatar gaetan-petit commented on July 21, 2024

@cedric-g : I'm on master with in my config.yml

lexik_form_filter:
    where_method: and

from lexikformfilterbundle.

cedric-g avatar cedric-g commented on July 21, 2024

I pushed a little change on master, can you try and check if it's ok ?

from lexikformfilterbundle.

gaetan-petit avatar gaetan-petit commented on July 21, 2024

@cedric-g Ha, I was just about to submit the same change in a PR 😛

It works like a charm with the change, thank you 😄

from lexikformfilterbundle.

raphox avatar raphox commented on July 21, 2024

1+
fixed with 49ed731

from lexikformfilterbundle.

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.