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
string
Table name
string
File name of page containing the table
string
Name of column to select on (caption)
string
SQL column name to order by
string
URL to return to after processing form
string
Database to use
string
Name of ID field in database
addActionLink(object $link) : void
object
Link instance
display(string $mode) : void
inherited_from | \Formaid_Form::display() |
---|
string
Mode 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. |
---|
string
Mode this function is working in (form, value)
string
getDisplayStringPrefix(string $mode) : string
string
Mode this function is working in (form, values)
string
getDisplayStringSuffix(string $mode) : string
string
Mode this function is working in (form, values)
string
getLinkCreateNew() : object
object
Link object pointing to modify record pagegetLinkModify() : object
object
Link 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
}
string
next 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 |
---|
int
record 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() |
---|
string
Mode 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 |
---|
string
action after validationallowAdd() : bool
If the Privilege on this record (allow_add) is set, it is allowed to add a new record.
bool
true if adding is allowed.allowCopy() : bool
If the Privilege on this record (allow_copy) is set, it is allowed to copy the record.
bool
true if copying is allowed.allowDelete() : bool
If the Privilege on this record (allow_delete) is set, it is allowed to delete the record.
bool
true 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() |
---|
bool
true if displaying is allowed.allowUpdate() : bool
If the Privilege on this record (allow_update) is set, it is allowed to update (edit) the record.
bool
true if updating is allowed.getSelectQueryResult() : array
array
query resultinitActionLinks() : void
postSubmitAction(string $submitType, string $message) : void
After an update (insert, update, delete) of a record, this method is executed.
access | protected |
---|
string
Submittype : insert, update, delete
string
Message for user to pass in the url
redirectToUrl(string $message) : void
Usually this happens after an insert/modify or delete
string
Message for user to pass in the url
_deleteDbValues(bool $redirect) : string
bool
redirect HTML page after insert (default : true)
string
message_insertDbValues(bool $redirect) : string
bool
redirect HTML page after insert (default : true)
string
message_updateDbvalues(bool $redirect) : string
bool
redirect HTML page after insert (default : true)
string
message$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 |
---|