A constant to help clarify that group zero is always index zero.
Filter a set of fields into a \Dewdrop\Fields\GroupedFields object.
Components that understand the additional APIs provided by \Dewdrop\Fields\GroupedFields object provides can then display their fields in user-defined groups, while components that are unaware of those APIs can continue using it just like a normal \Dewdrop\Fields object that is sorted in a particular order.
$dbAdapter : \Dewdrop\Db\Adapter
The DB adapter that can be used for loading and saving preferences.
__construct(string $componentName, \Dewdrop\Db\Adapter $dbAdapter)
Provide a component name and DB adpater that can be used when saving and loading preferences frmo the database.
getConfigForFields(\Dewdrop\Fields $fields) : array
Get an array representation of the current preferences. This is typically used by a UI/form designed to allow the user to modify the grouping and sorting preferences for a component. The resulting array will be in the following format:
array( 'title' => 'Group Title', 'caption' => 'Group caption explaining what it is. Usually only on unsorted group.', 'fields' => array( array( 'id' => 'products:name', 'label' => 'Name' ), array( 'id' => 'products:price', 'label' => 'Price' ) ) )
load() : array
Load the current preferences for this component from the database. The information will be returned in this format:
array( array( 'field_id' => 'products:name', 'group_title' => 'My Field Group', 'group_id' => 2 ) )
The fields and groups will be sorted when returned from this method, so can iterate over it without having to first sort it.
save(array $groupConfig) : \Dewdrop\Fields\Filter\Groups
Save the supplied configuration to the database. We expect the info to be provided in this format:
array( array( 'title' => 'My Group Title', 'fields' => array( array('id' => 'products:name'), array('id' => 'products:price') ) ) )
apply(\Dewdrop\Fields $currentFields) : \Dewdrop\Fields\GroupedFields
Apply the filter to the supplied set of fields. In return, you'll end up with a \Dewdrop\Fields\GroupedFields object that reflects the sort order and grouping preferences contained in this filter. You can use that object either as a normal \Dewdrop\Fields object or you can call getGroups() on it to get the fields back in their assigned groups.