Filters

Filters on grids act as predefined search options for each grid. Having a grid of objects you can filter out only those with a specified name, or value etc. Here you can find the supported filters. Keep in mind you can very easily define your own ones!

String

Simplest filter type. It can filter by one or multiple fields.

Filter by one field

Filter by multiple fields

Search options

This filter allows the user to select the following search options:

  • contains

  • not contains

  • equal

  • not equal

  • starts with

  • ends with

  • empty

  • not empty

  • in

  • not in

  • member of

If you don't want to display all these matching possibilities, you can choose just one of them. Then only the input field will be displayed. You can achieve it like this:

By configuring the filter as shown above, you will create an input field that filters user objects based on whether their username contains a given string.

Boolean

This filter checks if a value is true or false.

Date

This filter checks if a chosen datetime field is between given dates.

Entity

This type filters by a chosen entity.

Money

This filter checks if an amount is within the specified range and is in the selected currency

Warning

Providing different scale values between form_options and options may cause unwanted, and plausibly volatile results.

Exists

This filter checks if the specified field contains any value

Select

This type filters by a value chosen from the defined list

Creating a custom Filter

Sylius Grids come with built-in filters, but there are use-cases where you need something more than a basic filter. Grids let you define your own filter types!

To add a new filter, we need to create an appropriate class and form type.

Now you can use your new filter type in any grid configuration!

OR

Last updated

Was this helpful?