|
|
File: g:\Work\WWW\php\tbox\lib/cdbform.phps
PHP Documentation - PHP/Toolbox::Form
CDBForm
CSnippet | +-- CForm | +-- CDBForm
Basic database-driven form class.
|
private class CDBForm extends CForm
Basic database-driven form class.
The main idea is to use SQL-query meta-information
to automatically generate appropriate form fields.
On construction the controls may be put into control list in order
- to provide the user interface to named field that exists in the query;
- to ignore such a field;
- to provide the user interface to virtual field that isn't in the query but should be;
- to provide something like buttons, e.g. 'reset'.
|
|
Direct known subclasses: CDBQueryForm
|
|
Methods inherited from CForm |
cform, addcontrol, addvars, addsubmitcancel, setmode, getvalue, invalue, outvalue, outvalues, validatevalues, validatevalue, render, renderstart, renderend, rendercontrol, renderstartcontrol, renderendcontrol, write |
|
|
|
|
Method Summary |
|
()No additional comments. |
|
|
Fields inherited from CSnippet |
$id |
|
|
Public Method Details |
setList |
public void setList( string $table )
|
|
Constructs the SQL 'set' clause list with the fields that
belong to specified table, e.g.:
| do_query("insert into table_1 set ".setList("table_1");
|
Parameter |
|
string |
$table |
|
|
No additional comments. |
|
Returns |
void |
|
|
Private Method Details |
addControls |
private void addControls( $controls )
|
|
Overrides parent method to provide the special functionality.
In partucular, controls with 'dontadd' field set are skipped.
No additional comments.
|
Parameter |
|
|
$controls |
|
|
No additional comments. |
|
Returns |
void |
See Also |
addControl() |
|
get_infield |
private object CControl get_infield( array &$FIELD_DESCR, string $fname )
|
|
Take control from input list
and check whether the field is to be ignored
(fields with 'ignore' field set are skipped).
Otherwise, create the new CControl.
|
Parameter |
|
array |
&$FIELD_DESCR |
|
|
- the list of form controls. |
string |
$fname |
|
|
- field name. |
|
Returns |
object CControl |
|
setup_infield |
private void setup_infield( object CControl &$infield, string $fname, string $table, bool $required )
|
|
Sets up the control (infield) by providing it with:
- the field name;
- the display label;
- the table the field is originated from;
- validation data if the field is required;
- db lookup data if the field is a looking up one.
if they all aren't already set.
|
Parameter |
|
object CControl |
&$infield |
|
|
- inout field control. |
string |
$fname |
|
|
- field name. |
string |
$table |
|
|
- guess! |
bool |
$required |
|
|
- guess! |
|
Returns |
void |
|
set_lookup_options |
private void set_lookup_options( object CControl &$infield, [ integer $options ] )
|
|
Sets up the lookup data to specified infield.
If the options isn't specified excplicitely, executes the lookup query
and sets the lookup data as key=>value pairs.
Note the lookup query format:
| new CSelect(array( # for example
| "lookup" => "looked_key_field as op_label, looked_value_field as op_value from looked_table"
| ...
| ));
Hope, it's clear enough.
|
Parameter |
|
object CControl |
&$infield |
|
|
- inout field control. |
integer |
$options |
= >>0<<
|
|
- to specify the options excplicitely. |
|
Returns |
void |
|
|
Private Constant Details |
MAX_FIELD_LENGTH
define( MAX_FIELD_LENGTH, >>250<< )
Case: default: case sensitive
|
|
|
|
|
PHPDoc 1.0beta |