Class mySqlForm

Description

Class contains contains class for creating forms from a db tables schema

Located in /lib/mySqlForm.php (line 21)

db
   |
   --mySqlForm
Variable Summary
array $dbFields
object holding $form
array $formFields
string $id
array $labels
array $many
string $method
string $table
Method Summary
mySqlForm __construct (string $table, array $fields, [array $initValues = null])
void createForm (string $action, [string $method = 'post'], [string $name = ''], [string $target = ''], [string $enctype = ''], [string $caption = ''])
void setLabels (array $labels)
void setMethod (string $method, [ $id = null])
void setToMany (string $field, string $table, string $id, string $title, [string $type = 'dropdown'])
Variables
array $dbFields (line 45)
  • var: holding db fields set by mysql with "describe `table`"
  • access: public
array $defaultValues = array() (line 81)
  • var: var for containing values when updating displayed in form updating the form
  • access: public
object holding $form (line 33)
  • var: form object
  • access: public
array $formFields (line 52)
  • var: array holding fields to be used when displaying the form
  • access: public
string $id = 'id' (line 27)
  • var: name of column id - change this if id of table is not 'id'
  • access: public
array $labels (line 74)
  • var: labels containing labels for form fields in an array
    1. array('title' => 'Enter title')
    This will be mapped as the labels in the form
  • access: public
array $many = array() (line 66)
  • var: containg fields which will be mapped to other tables. usefull when you want to display a select element with e.g. categories.
  • access: public
string $method (line 58)
  • var: crud method to use method to use: update, insert or delete
  • access: public
string $table (line 39)
  • var: holding table name to use with creation of the form
  • access: public

Inherited Variables

Inherited from db

db::$dbh
db::$debug
Methods
Constructor __construct (line 91)

constructor which sets the table and fields to use from database when creating the form.

mySqlForm __construct (string $table, array $fields, [array $initValues = null])
  • string $table: the table to use when creating the form.
  • array $fields: if set the fields to use with the form.
  • array $initValues: defulat init values when inserting

Redefinition of:
db::__construct()
constructor will try to call method connect
createForm (line 226)

Method that will create the actual form

Same documentation as in PEAR::HTML_Form

  • access: public
void createForm (string $action, [string $method = 'post'], [string $name = ''], [string $target = ''], [string $enctype = ''], [string $caption = ''])
  • string $action: the string naming file or URI to which the form should be submitted
  • string $method: a string indicating the submission metho 'get' or 'post')
  • string $name: a string used in the <form>'s 'name' attribute
  • string $target: a string used in the <form>'s 'target' attribute
  • string $enctype: a string indicating the submission's encoding
  • string $caption: a string of additional attributes to be put in the element (example: 'id="foo"')
setLabels (line 104)
  • access: public
void setLabels (array $labels)
  • array $labels: labels for form elements.
setMethod (line 114)

method for setting crud method (no read)

  • access: public
void setMethod (string $method, [ $id = null])
  • string $method: insert, update or delete.
  • $id
setToMany (line 170)

method for creating a connection to another table. E.g. if we have a dropdown with categories from another table and want to display this category as a dropdown of options, we use setToMany

  • access: public
void setToMany (string $field, string $table, string $id, string $title, [string $type = 'dropdown'])
  • string $field: field which field do we map to many
  • string $table: table which table do we use in db
  • string $id: id which column will act as id ('id')
  • string $title: title which column will act as title
  • string $type: type (only dropdown is supported right now)

Inherited Methods

Inherited From db

db::__construct()
db::connect()
db::delete()
db::fatalError()
db::getDebug()
db::getNumRows()
db::insert()
db::prepareToPost()
db::rawQuery()
db::select()
db::selectAll()
db::selectOne()
db::selectQuery()
db::simpleSearch()
db::simpleSearchCount()
db::update()

Documentation generated on Fri, 17 Dec 2010 17:56:36 +0100 by phpDocumentor 1.4.3