Skip to content

The adminTable class

abidibo edited this page Mar 21, 2012 · 34 revisions

This is the Jeff's noblest class. It creates a default back-office interface for managing a database table (which has a primary key field). It gets the table structure directly from the database and constructs a navigation view to surf through inserted data, an insertion/edit view (the form) to add or update records and all the necessary actions to perform insertion, modification, deletion and exportation.

The adminTable class can also manage automatically foreign keys, some particular fields (password, bool, enum, email, multicheck, file, image), html fields (charging dojo html editor if needed) and fields managed by extra plugins.

Also it is possible to automatically add filters for the list view. It's enough to set the filters fields and the class adds for you the filters form and performs the research. Filters field may be text, int, float, bool and foreign keys fields.

So if it's not necessary to have a specific logic that regulates the access and actions doable over a database table, with few lines of code is possible to create the entire table back office, sounds good, true? All you have to do is set the foreign keys and/or special fields if needed and then call the manage method. Then Jeff shows you a list of inserted records with the possibility to edit/delete them or insert a new one. All these operations are managed automatically by the manage method.

In alternative you may use only some features of this class, like using only the records paginated list (setting as not editable the fields: edit_deny='all') or using only the auto generated form.

Clearly even if the module requires something different, it's always possible to extend this class in order to overwrite only the aspects that need a proper customization.

Clone this wiki locally