Db_FilterBehavior class
Defined in |
/phproad/modules/db/behaviors/db_filterbehavior.php, lines 25-461 |
Inheritance |
Phpr_Extension » Phpr_ControllerBehavior » Db_FilterBehavior |
Author |
LemonStand eCommerce Inc. |
Adds list filters features to back-end controllers.
This class allows to extend any back-end controller with a list filters functionality.
The extension can be added to a controller by listing the class name in the $implement property of the controller class:
class AbcBlog_Posts extends Backend_Controller
{
public $implement = 'Db_FilterBehavior, Db_ListBehavior, Db_FormBehavior';
...
To configure the extension, its properties should be defined in the extended controller class.
Filter classes should be defined separately and be inherited from the Db_DataFilter class. Please refer to the
Administration Area Filters article for the usage examples and details.
Property |
Type |
Description |
Defined By |
filter_filters |
array |
a list of filter configurations. |
Db_FilterBehavior |
filter_list_title |
string |
specifies the filters title. |
Db_FilterBehavior |
Property details
¶
filter_filters property
public array $filter_filters;
A list of filter configurations.
Each element of this array should have a unique index and contain a list of filter configuration options:
- name - a filter name to display on the filter panel.
- class_name - a filter class name. Filter classes should be defined separately.
- prompt - a message to display above a list of available filter records in the filter configuration popup form.
- added_list_title - a title to display above the list of selected filter records.
Example:
public $filter_filters = array(
'status'=>array(
'name'=>'Current Order Status',
'class_name'=>'Shop_OrderStatusFilter',
'prompt'=>'Please choose order statuses',
'added_list_title'=>'Added Statuses'),
'products'=>array(
'name'=>'Product',
'class_name'=>'Shop_ProductFilter',
'prompt'=>'Please choose products',
'added_list_title'=>'Added Products')
)
¶
filter_list_title property
public string $filter_list_title;
Specifies the filters title.
The default value is Filters.
Method details
¶
filterApplyToModel() method
$model |
Db_ActiveRecord |
a model object to apply filters to. |
$context |
string |
specifies the filter context name. |
{return} |
Db_ActiveRecord |
returns a configured model object. |
Applies filters to a model.
Use this filter to apply configured filter to a model. If you use the
List Behavior, this method should be called in the
listPrepareData() class overridden
in the controller. Example:
public function listPrepareData()
{
$obj = Shop_Order::create();
$this->filterApplyToModel($obj);
return $obj;
}
¶
filterRender() method
public void filterRender()
Renders a filter settings.
When filters are used with the List Behavior, this method is not used.
The list behavior calls this method internally if its $list_render_filters
property value is TRUE.
|