How to to pre-filter a Bootstrap Admin READ list?
PHP CRUD Tutorial

The READ lists filters are stored in PHP $_SESSION.


To register a filter value to pre-filter a table READ list:

The filters main class is admin/class/crud/ElementsFilters.php

This PHP class manages all the stuff concerning the filters: it builds the filters forms, registers the posted filter value and builds the table's filter JOIN query.


All the filters are stored in PHP $_SESSION with the following naming convention:

// "table" is your DB table name
// "fieldname" is your DB field name
$_SESSION['filters-list']['table_filter_fieldname']

For instance, if you've got a table named "customer" and want to pre-filter the "firstname" field:

$_SESSION['filters-list']['customer_filter_firstname'] = 'John';

To reset a filter value to show all the records:

The default filter value is 'all'.

$_SESSION['filters-list']['customer_filter_firstname'] = 'all';

Back to the PHP CRUD Tutorials