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.

  1. $filterInputs['group_id'] = array('label'=>'Filter by Group', 'all'=>true);

Default All Functionality

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.

  1. $filterInputs['group_id'] = array('label'=>'Filter by Group', 'all'=>'My Label');

 Specifiying a custom label for All Results

  1. $filterInputs['group_id'] = array('label'=>'Filter by Group', 'all'=>array('value'=>'my-value', 'label'=>'My Label'));

Making a custom label and custom value for All Results Filtering

Tip: using the custom label and custom value option for All Records is useful when integrating with legacy computer systems.

1-207-221-3255 | Contact Site Avenger - Your Content Management Superhero

Copyright © 2023 Saco Design, Inc. | All Rights Reserved | Website Design by Saco Design | Superpowered by Site Avenger