$Id: tabledit.html 4887 2024-04-15 13:42:46Z honzam $
This is a multi-purpose class allowing to edit various tables. It works based on a configuration array called Table View.
Remarks for developers are in tabledit_developer.html.
The main features are:
The Browse view is used to view many records at once. It is a table with one row for each table record. If there are many records, a scroller is shown under the table allowing to jump through the records. A search form may be shown to quickly find records. After clicking on the Edit image on the left of a record or on Insert under the table you usually go to an Edit view, set by "gotoview" (see Table View grammar).
id |
description |
standard |
editorial |
From: mail header |
Reply-To: |
Errors-To: |
Sender: |
The Edit view is used to edit a record. Each field is shown on a separate row. Usually only one record is shown although you may show more if you wish.
Input is first validated by JavaScript before sending the form and again by PHP itself. See Table View grammar for validation types.
For the styles used and their definition see some source generated by TableEdit
and the tabledit.css
style sheet.
An important feature of TableEdit is showing tables with Parent - Child (1:n) relationships.
A 1:n (one-to-many) relationship means that 1 record in a Parent table is connected by key values to many records in the Child table.
For example table Countries contains Czech republic with ID 54 and table Towns contains records (54, Praha), (54, Brno), (54, Ostrava) etc.
The usual way to view one-to-many related tables is to use Edit view to show one parent record and one or more Browse view with related children records. Use "children" in the Table View definition to create such a view.
A m:n (many-to-many) relationship always needs 3 tables A, B, C, with relationship 1:n between A and B and 1:n between C and B. Table B contains the relation info, i.e. keys from both A and C. To view such a relationship you may use a child view on one 1:n relationship (e.g. parent A and child B) and use a select box which maps keys from C (as OPTION values) to some other field from C.
For example A = country, B = place, C = place type (city / town / village). You may have records like (54, Praha, city), (54, Brno, town), (54, Ostrava, town) in table B and (1,city), (2,town), (3,village) in table C. You view A as parent, B as child and the field typeID from table B is shown as a select box with values got from C.
The class usage is quite simple. Create a new class by constructor, see include/tabledit.php
source for exact parameter description. One of the parameters is the current
URL, TableEdit uses session to move with scroller and to store other parameters.
Call the view() function. See admin/tabledit.php
for an example.
Uses PHPLib Database and Session objects (set externally).
Uses AA CVarset and Scroller objects, ValidateInput() and other functions.
Uses AA mini gettext language environment.