QZ Forms

Table Actions

A table action is an SQL prepared statement created with $n notation for variables ($1,$2,). There is a list of fieldnames, the value for each is extracted from the HTTP post data and placed in the correct slot for the prepared statement. A list of primary key attributes may be specified. On form generation, these will be presented as read only fields.

A form name and an action specify a table action. When the form is created, a handler is specified. Each handler has its own set of supported actions.

onetable

list
list is the main starting point for managing the data. It should select only a few attributes. Each row from the DB table will be a row in the HTML table with an edit button to update that row.
create
An SQL command that creates data for a new record without necessarily updating the db. Frequently this is done as
SELECT ''::text someattribute
but can also be a call to a PLSQL script
SELECT someattribute FROM somefunction($1,$2)
insert
Insert one new record after create has presented it and the user hits submit on their form.
edit
Presents one row of the table for editing.
update
Updates one record after edit has presented it and the user hits submit on their form.
delete
Delete one row. The fieldnames almost always should be the primary key.

grid

edit
A select statement that returns all the rows and attributes to be edited. The data will be presented in an HTML table.
save
In most cases, this is a no-op. It must exist so that the save button on the users page has a corresponding action. Commonly
SELECT 1
or other mindless nothing.
insert_row
A command to insert one row. If not present, then the "Add Row" button will not be on the edit page.
update_row
A command to update one row.
delete_row
A command to delete one row. If not present, then the "Delete" button will not be on the edit page.

menu

view
The view action is a a no-op. Its existence enables a menu page.
SELECT 1
A menu, which is a set of menu items, can exist on any form page. The menu handler is unique not for what it does, but in that it does nothing else except hold menus.

fs

get
Unlike onetable and grid, the fs handler has no way to handle attributes other than the following:
  • filename - no spaces or funny symbols
  • mimetype - "text/javascript", "text/css"
  • modtime - timestamp
  • etag - a 64 bit unsigned integer that changes on every update.
  • data - The contents of the file as one string of bytes, no nulls.
etag_value
Return just the etag. This is tied to an "if modified" HTTP request to preserve cache coherency.