Creating a custom DataGrid filter

86 views
Skip to first unread message

Simon Ball

unread,
Jun 6, 2016, 4:19:55 AM6/6/16
to sonata-devs
I'm using MongoDB and trying to recreate the AJAX search using in formMapper but in dataGrid instead. So far:
  • Added a service and config parameter for doctrine_mongodb_autocomplete to doctrine_mongodb_filter_types.xml

<parameters>
   
<parameter key="sonata.admin.odm.filter.type.autocomplete.class">Sonata\DoctrineMongoDBAdminBundle\Filter\AutocompleteFilter</parameter>
</parameters>

<services>
       
<service id="sonata.admin.odm.filter.type.autocomplete" class="%sonata.admin.odm.filter.type.autocomplete.class%">
           
<tag name="sonata.admin.filter.type" alias="doctrine_mongo_autocomplete" />
       
</service>
</services>

  • Copied the ModelFilter type to AutocompleteFilter to DoctrineMongoDBAdminBundle/Filter/AutocompleteFilter.php

So far, exactly the same as the ModelFilter except

class AutocompleteFilter extends Filter

  • Added an AutocompleteType to admin-bundle/Form/Type/Filter/AutocompleteType.php

So far, exactly the same as namespace Sonata\AdminBundle\Form\Type\ModelAutocompleteType.php

  • Added an extra type to the formContractor similar to the one located in the ORM bundle (just in case?)

When I try to actually use the filter,  Symfony complains about the unrecognised type though. Please can someone give me a poke in the right direction.


Kind regards

Simon

Reply all
Reply to author
Forward
0 new messages