Skip to content

SortableFieldInterface ​

Type
Interface
Namespace
craft\base
Implemented by
craft\fields\Date, craft\fields\Dropdown, craft\fields\Lightswitch, craft\fields\Number, craft\fields\PlainText, craft\fields\RadioButtons, craft\fields\Time
Since
3.2.0

SortableFieldInterface defines the common interface to be implemented by field classes that can be available as sort options on element indexes.

View source

Public Methods ​

MethodDescription
getSortOption()Returns the field’s sort option definition.

getSortOption() ​

Returns the field’s sort option definition.

This should return an array with the following keys:

  • label – The sort option label
  • orderBy – An array or comma-delimited string of columns to order the query by
  • attribute – The table attribute name that this option is associated with (required if orderBy is an array or more than one column name)

View source

Returns ​

array