A record form adds, updates or deletes data in a database record.
This class, adds several html-fields (text, selection box, ...) to a form, and the necessary buttons (Add, Update, Delete, Copy). It provides the logic for : - inserting a new record to a database - modifying data of an existing record - deleting an existing record - copying the values of an existing record, to a new form - validating the values of the fields
| category | Form |
|---|---|
| package | Formaid |
| author | Dieter Adriaenssens |
| copyright | 2006-2013 Dieter Adriaenssens |
| license | GPL |
| link | http://formaid.sourceforge.net/ |
__construct(string $table_name, string $file_name, string $field_selectionname, string $orderby, string $return_url, string $database, string $idName) : void
stringTable name
stringFile name of page containing the table
stringName of column to select on (caption)
stringSQL column name to order by
stringURL to return to after processing form
stringDatabase to use
stringName of ID field in database
addActionLink(object $link) : void
objectLink instance
display(string $mode) : void
| inherited_from | \Formaid_Form::display() |
|---|
stringMode this function is working in (form, value)
displayValues() : void
Execute display() method in "values" mode. In this mode, no form is displayed, but the values of the record are printed on the webpage. The values can't be edited.
| inherited_from | \Formaid_Form::displayValues() |
|---|
getDisplayString(string $mode) : string
If the mode is form, a form is shown : this includes a title, form tags and form fields (input boxes, ...) If the mode is value, only the values of a record are shown, there is no possibility to change and submit values.
| todo | move generating of buttons to a seperate method, so that the parent function can be used, limiting the amount of duplicate code. |
|---|
stringMode this function is working in (form, value)
stringgetDisplayStringPrefix(string $mode) : string
stringMode this function is working in (form, values)
stringgetDisplayStringSuffix(string $mode) : string
stringMode this function is working in (form, values)
stringgetLinkCreateNew() : object
objectLink object pointing to modify record pagegetLinkModify() : object
objectLink object pointing to modify record pageprepareRun() : string
This function checks if a form was submitted and takes appropriate actions : - insert data in a database (add a new record) - update data in a database (modify an existing record) - remove data from a database (delete an existing record) - copy data in current form (creates a new form, omitting the record ID)
After validating the data in the form, the requested action is executed and the next action is returned : - show (a form can be displayed) - null (nothing can be displayed, a redirect is necessary)
Use prepareRun() and evaluate the output when you use a custom header and footer, or when you use custom output. Example : if ($form->prepareRun() == "show") { // output header
$form->display();
// output footer
}
stringnext actionreadValues(int $ID) : void
Basically, this is an API to read data from a database record. If ID is specified, it will execute a SELECT query to retrieve a record, if the ID it is not specified, data is read from POST values.
| access | public |
|---|
intrecord ID
run() : void
prepareRun() is called to check if there was a submit request and execute it. If prepareRun() returns next action "show", a form is displayed.
Example : $form->run();
| see | \prepareRun() |
|---|
show(string $mode) : void
| inherited_from | \Formaid_Form::show() |
|---|
stringMode this function is working in (form, value)
showValues() : void
Execute display() method in "values" mode. In this mode, no form is displayed, but the values of the record are printed on the webpage. The values can't be edited.
| inherited_from | \Formaid_Form::showValues() |
|---|
updateDbValues() : void
Basically, this is an API to create/update data in a database record, without having to submit a form request. If ID is specified, it will update a record, if it is not specified, a new record will be created and the new ID will assigned to ID object.
| access | public |
|---|
validate() : string
All record forms are validated, depending on the result, the next action is defined (run, display form, ...)
| todo | low : validate values |
|---|
stringaction after validationallowAdd() : bool
If the Privilege on this record (allow_add) is set, it is allowed to add a new record.
booltrue if adding is allowed.allowCopy() : bool
If the Privilege on this record (allow_copy) is set, it is allowed to copy the record.
booltrue if copying is allowed.allowDelete() : bool
If the Privilege on this record (allow_delete) is set, it is allowed to delete the record.
booltrue if deleting is allowed.allowShow() : bool
If the Privilege on this form (allow_show) is set, it is allowed to display the form.
| inherited_from | \Formaid_Form::allowShow() |
|---|
booltrue if displaying is allowed.allowUpdate() : bool
If the Privilege on this record (allow_update) is set, it is allowed to update (edit) the record.
booltrue if updating is allowed.getSelectQueryResult() : array
arrayquery resultinitActionLinks() : void
postSubmitAction(string $submitType, string $message) : void
After an update (insert, update, delete) of a record, this method is executed.
| access | protected |
|---|
stringSubmittype : insert, update, delete
stringMessage for user to pass in the url
redirectToUrl(string $message) : void
Usually this happens after an insert/modify or delete
stringMessage for user to pass in the url
_deleteDbValues(bool $redirect) : string
boolredirect HTML page after insert (default : true)
stringmessage_insertDbValues(bool $redirect) : string
boolredirect HTML page after insert (default : true)
stringmessage_updateDbvalues(bool $redirect) : string
boolredirect HTML page after insert (default : true)
stringmessage$ID : object
| access | public |
|---|
$data : array
| access | public |
|---|---|
| inherited_from | \Formaid_Form::$$data |
$filename : string
| access | public |
|---|---|
| inherited_from | \Formaid_Form::$$filename |
$form_select : object
| access | public |
|---|
$minItemsActionLinks : integer
| access | public |
|---|
$privileges : array
| access | public |
|---|---|
| inherited_from | \Formaid_Form::$$privileges |
$return_url : string
| access | public |
|---|---|
| inherited_from | \Formaid_Form::$$return_url |
$sql_table : string
| access | public |
|---|---|
| inherited_from | \Formaid_Form::$$sql_table |
$title : string
| access | public |
|---|---|
| inherited_from | \Formaid_Form::$$title |
$urlOverview : string
| access | public |
|---|
$db_connection : object
| access | protected |
|---|---|
| inherited_from | \Formaid_Form::$$db_connection |
$encoding : string
| access | protected |
|---|---|
| inherited_from | \Formaid_Form::$$encoding |
$_actionLinks : object
..).
| access | private |
|---|