Creating Filtering Forms using Avtemplate Helper
Adding an Option for All
In most circumstances, adding an option for All Records is as easy as NOT adding any conditions. This scenario can be accomplished very easily using the $avtemplate->filterForm() function.
On the filter input, specify 'all'=>true. By default, 'all' is false.
Tip: you can determine if all has been selected by looking for $this->data['Avfilter']['submit'] or $params['avfilter.submit'] in the absence of any other data being posted.
If you actually need to specify a key that you will use to invoke filter (use case: "all orders" is all completed orders, not all incomplete orders). You have two options, use 'all' as the value or make a custom value.
- $filterInputs['group_id'] = array('label'=>'Filter by Group', 'all'=>array('value'=>'my-value', 'label'=>'My Label'));
Tip: using the custom label and custom value option for All Records is useful when integrating with legacy computer systems.