Important

You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Filter Form Types

Filter Form Types are PHP classes that represent filters and extend standard Symfony form types. Each filter form type is a compound and consists of two fields:

  • a field for filter value (named “value”)

  • a field for filter operator (named “type”)

The following filters form types are available:

Class

Name

Short Description

FilterType

oro_type_filter

Basic type for all filters, declares two children value and type

TextFilterType

oro_type_text_filter

Represents text filter form

NumberFilterType

oro_type_number_filter

Represents number filter form

NumberRangeFilterType

oro_type_number_range_filter

Represents number range filter form

ChoiceFilterType

oro_type_choice_filter

Represents choice filter form

EntityFilterType

oro_type_entity_filter

Represents entity filter form

BooleanFilterType

oro_type_boolean_filter

Represents boolean filter form

DateRangeFilterType

oro_type_date_range_filter

Represents date filter form

DateTimeRangeFilterType

oro_type_datetime_range_filter

Represents date and time filter form

DateRangeType

oro_type_date_range

This form type is used by oro_type_date_range_filter as field type

DateTimeRangeType

oro_type_datetime_range

This form type is used by oro_type_datetime_range_filter as field type

SelectRowFilterType

oro_type_selectrow_filter

This form type is used by datagrid extension only

DateGroupingFilterType

oro_type_date_grouping_filter

Represents date grouping filter

SkipEmptyPeriodsFilterType

oro_type_skip_empty_periods_filter

Represents skip empty periods filter

oro_type_filter Form Type

Children

  • value

  • type

Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

Default Options

  • field_type = TextType::class

  • operator_type = ChoiceType::class

  • show_filter = False

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\FilterType

Options Description

  • field_type - This option declares type of value child element.

  • field_options - Value of this option will be used as options array for value field.

  • operator_choices - Value of this option will be used as value of “choices” option of type field.

  • operator_type - This option declares type of type child element. By default has “choice” value.

  • operator_options - Value of this option will be used as options array for type field.

  • show_filter - If FALSE then filter will be hidden when it’s rendered in filter list.

oro_type_text_filter Form Type

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

Default Options

  • field_type = text

  • operator_choices

    • TextFilterType::TYPE_CONTAINS

    • TextFilterType::TYPE_NOT_CONTAINS

    • TextFilterType::TYPE_EQUAL

Parent Type

oro_type_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\TextFilterType

JS Class

ro.Filter.TextFilter

oro_type_number_filter Form Type

Options

  • data_type

  • fromatter_options

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

Default Options

  • field_type = text

  • operator_choices

    • NumberFilterType::TYPE_GREATER_EQUAL

    • NumberFilterType::TYPE_GREATER_THAN

    • NumberFilterType::TYPE_EQUAL

    • NumberFilterType::TYPE_LESS_EQUAL

    • NumberFilterType::TYPE_LESS_THAN

  • data_type = NumberFilterType::DATA_INTEGER

Parent Type

oro_type_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\NumberFilterType

JS Class

Oro.Filter.NumberFilter

Options

  • data_type - This option can be used for configuration of value field type. Can be a value of one of constants: ::DATA_INTEGER or NumberFilterType::DATA_DECIMAL.

formatter_options

In addition to data_type option, this option can contain parameters for number formatter that is used by value field. Available attributes are:

  • decimals - maximum fraction digits

  • grouping - use grouping to separate digits

  • orderSeparator - symbol of grouping separator

  • decimalSeparator - symbol of decimal separator.

oro_type_number_range_filter Form Type

Options

  • data_type

  • formatter_options

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

Default Options

  • field_type = text

  • operator_choices

    • NumberRangeFilterType::TYPE_BETWEEN

    • NumberRangeFilterType::TYPE_NOT_BETWEEN

    • NumberRangeFilterType::TYPE_GREATER_EQUAL

    • NumberRangeFilterType::TYPE_GREATER_EQUAL

    • NumberRangeFilterType::TYPE_GREATER_THAN

    • NumberRangeFilterType::TYPE_EQUAL

    • NumberRangeFilterType::TYPE_LESS_EQUAL

    • NumberRangeFilterType::TYPE_LESS_THAN

    • FilterUtility::TYPE_EMPTY

    • FilterUtility::TYPE_NOT_EMPTY

  • data_type = NumberFilterType::DATA_INTEGER

Parent Type

oro_type_number_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\NumberRangeFilterType

JS Class

Oro.Filter.NumberRangeFilter

Options

  • data_type - This option can be used for configuration of value field type. Can be a value of one of constants: NumberFilterType::DATA_INTEGER or NumberFilterType::DATA_DECIMAL.

formatter_options

In addition to data_type option, this option can contain parameters for number formatter that is used by value field. Available attributes are:

  • decimals - maximum fraction digits

  • grouping - use grouping to separate digits

  • orderSeparator - symbol of grouping separator

  • decimalSeparator - symbol of decimal separator.

oro_type_choice_filter Form Type

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

Default Options

  • field_type = choice

  • operator_choices

    • ChoiceFilterType::TYPE_CONTAINS

    • ChoiceFilterType::TYPE_NOT_CONTAINS

Parent Type

oro_type_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\ChoiceFilterType

JS Classes

Oro.Filter.MultiSelectFilter Oro.Filter.SelectFilter

oro_type_entity_filter Form Type

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

Default Options

  • field_type = entity

Parent Type

oro_type_choice_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\EntityFilterType

JS Classes

Oro.Filter.MultiSelectFilter Oro.Filter.SelectFilter

oro_type_boolean_filter Form Type

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

Default Options

  • field_options = choices

    • BooleanFilterType::TYPE_YES

    • BooleanFilterType::TYPE_NO

Parent Type

oro_type_choice_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\BooleanFilterType

JS Class

Oro.Filter.SelectFilter

oro_type_date_range_filter Form Type

Options

  • widget_options

  • type_values

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

Default Options

  • field_type = oro_type_date_range

  • widget_options = array(“dateFormat” => “mm/dd/yy”, “firstDay” => 0)

  • operator_choices

    • DateRangeFilterType::TYPE_BETWEEN

    • DateRangeFilterType::TYPE_NOT_BETWEEN

  • type_values

    • DateRangeFilterType::TYPE_BETWEEN

    • DateRangeFilterType::TYPE_NOT_BETWEEN

Parent Type

oro_type_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\DateRangeFilterType

JS Classes

Oro.Filter.DateFilter

Options Description

  • widget_options - Value of this option will be used by javascript widget to correctly display its data. Default value of this option depend from of current application locale options.

  • type_values - Value of this option will be used by javascript widget to generate valid hint of current filter value (strings like “between %start% and %end%”, “before %start%”, “after %end%”, “not between %start%”, etc)

oro_type_datetime_range_filter Form Type

Options

  • widget_options

  • type_values

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

  • type_values

  • widget_options

Default Options

  • field_type = oro_type_datetime_range

  • widget_options = array(“dateFormat” => “mm/dd/yy”, “timeFormat” => “hh:mm tt”, “firstDay” => 0)

Parent Type

oro_type_date_range_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\DateRangeFilterType

JS Classes

Oro.Filter.DateFilter

oro_type_date_range Form Type

Children

  • start

  • end

Options

  • field_type

  • field_options

  • start_field_options

  • end_field_options

Default Options

  • field_type = “date”

Class

Oro\Bundle\FilterBundle\Form\Type\DateRangeType

Options Description

  • field_type - This option declares type of start and end child elements.

  • field_options - Value of this option will be used as options array for start and end fields.

  • start_field_options - Value of this option will be used as options array for start field.

  • end_field_options - Value of this option will be used as options array for end field.

oro_type_datetime_range Form Type

Default Options

  • field_type = “datetime”

Parent Type

oro_type_date_range

Class

Oro\Bundle\FilterBundle\Form\Type\DateTimeRangeType

oro_type_selectrow Form Type

Provides filtering by selected/not selected rows in datagrid

Default Options

  • field_type = “choice”

Parent Type

oro_type_filter

Class

Oro\Bundle\FilterBundle\Form\Type\SelectRowFilterType

oro_filter.form.type.date_grouping

oro_type_date_grouping_filter Form Type

Options

  • data_name

  • joined_column

  • not_nullable_field

  • calendar_entity

  • target_entity

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

  • field_type

  • operator_choices

Default Options

  • calendar_table = “calendarDate”

  • calendar_column = ‘date’

  • calendar_table_for_grouping = ‘calendarDate1’

  • calendar_column_for_grouping = ‘date’

  • joined_table = ‘joinedTableAlias’

  • target_column = ‘date’

Parent Type

oro_type_choice_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\DateGroupingFilterType

JS Classes

Oro.Filter.MultiSelectFilter Oro.Filter.SelectFilter

oro_type_skip_empty_periods_filter Form Type

Options

  • not_nullable_field

Inherit Options

  • field_type

  • field_options

  • operator_choices

  • operator_type

  • operator_options

  • show_filter

  • field_type

  • operator_choices

Parent Type

oro_type_choice_filter

Class

Oro\Bundle\FilterBundle\Form\Type\Filter\DateGroupingFilterType

JS Classes

Oro.Filter.MultiSelectFilter Oro.Filter.SelectFilter

Example of Usage

You can use filter form types as any other form type in Symfony. For example, consider you have a form with three filters. In your form type you should add code like this:

 1 class MyFilterFormType extends AbstractType
 2 {
 3     public function buildForm(FormBuilderInterface $builder, array $options)
 4     {
 5         // Add some form fields
 6         // ...
 7         // Add filters
 8         $builder->add('name', 'oro_type_text_filter');
 9         $builder->add('salary', 'oro_type_number_filter');
10         $builder->add('hobby', 'oro_type_choice_filter', array(
11         field_options' => array(
12                 'choices' => array(1 => 'Coding', 2 => 'Hiking', 3 => 'Photography'),
13                 'multiple' => true
14             )
15         ));
16     }
17 }

References