Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: g:\Work\WWW\php\tbox\lib/cform.phps
PHP Documentation - PHP/Toolbox::Form

CForm

CSnippet
  |
  +-- CForm

The main form class.

 

private class CForm extends CSnippet

The main form class.
The general CForm usage follows: | $form = new CForm("Html_Handler_Suffix", array( | "field_1" => new CControl(array( | "label" => "Field 1", | ... | )), | "field_2" => new CControl(array( | "label" => "Field 2", | ... | )), | ... | )); | $form->addSubmitCancel("Submit_Label", "Cancel_Label"); | $form->render(); Html_Handler_Suffix specifies the class CFormHandler that's responsible for the form rendering. It's also possible to render the form manually: | <table> | <tr> | <td>Label</td> | <td><?$form->renderControl($form->controls["name"]);?></td> | </tr> | </table>

 
Direct known subclasses: CDBForm

Methods inherited from CSnippet

csnippet, append, qualify, getglobal, setglobal, flush, writecode

Public Method Summary

void

CForm(string $handler, [ array $controls, string $action, string $method, string $attrs ])

Constructor.
void

addControls( $controls)

Adds the list of controls.
void

addVars([ string $HTTP_VARS, string $type ])

Adds vars from the specified array.
void

addSubmitCancel([ string $submit, string $cancel ])

Adds SUBMIT/CANCEL buttons.
string

setMode(string $newMode)

Sets the form mode.
bool

validateValues()

Use this to validate form data.
void

render()

Main rendering method.
void

renderControl( &$control)

Use this to insert controls manually

Private Method Summary

void

addControl(string $name, object CControl $control)

Adds the control.
mixed

getValue(object CControl $control)

Returns value from the specified control.
mixed

inValue(object CControl $control, mixed $value)

Control's value to input to form.
mixed

outValue(object CControl $control)

Control's value to output from the form.
array

outValues()

Collects output values of the form.
mixed

validateValue(object CControl $control)

Use this to override the data verification on the form level,
void

renderStart()

Use this to insert the form caption manually
void

renderEnd()

Use this to insert the form ending manually
void

renderStartControl( &$control)

Use this to insert the control prefix (e.g. label) manually
void

renderEndControl( &$control)

Use this to insert the control ending manually
void

write( $s)

Just 'echoes' the string by default.No additional comments.

Fields inherited from CSnippet

$id

Private Field Summary

string

$mode

Form mode.
unknown

$action

Form action. *
unknown

$method

Form method.
unknown

$controls

Private Constant Summary

NO_INDEX >>-1<<

Public Method Details

CForm

public void CForm( string $handler, [ array $controls, string $action, string $method, string $attrs ] )

  Constructor.

Parameter
string $handler
- name of the form html handler.
array $controls = >>array()<<
- array of controls.
string $action = >>""<<
- form action.
string $method = >>'get'<<
- form method.
string $attrs = >>""<<
- form extra attrs
Returns void


addControls

public void addControls( $controls )

  Adds the list of controls.

Parameter
$controls
No additional comments.
Returns void

See Also addControl()

addVars

public void addVars( [ string $HTTP_VARS, string $type ] )

  Adds vars from the specified array.
Uses HTTP_GET_VARS and type=hidden by default.

Parameter
string $HTTP_VARS = >>"HTTP_GET_VARS"<<
- array's *name*.
string $type = >>"hidden"<<
- controls' type.
Returns void


addSubmitCancel

public void addSubmitCancel( [ string $submit, string $cancel ] )

  Adds SUBMIT/CANCEL buttons.
Besides, it adds all work stuff.

Parameter
string $submit = >>SUBMIT,<<
- name.
string $cancel = >>CANCEL<<
- name.
Returns void


setMode

public string setMode( string $newMode )

  Sets the form mode.
Besides, it adds all work stuff.

Parameter
string $newMode
- new mode.
Returns string

- old mode.


validateValues

public bool validateValues( )

  Use this to validate form data.

Returns bool

- TRUE if error occured.


render

public void render( )

  Main rendering method.
Use this to render the whole form body.

Returns void


renderControl

public void renderControl( &$control )

  Use this to insert controls manually
$form->renderControl($form->controls["name"]);
and/or to override the method. It calls $control->{"render$this->mode"}() by default.

Parameter
&$control
No additional comments.
Returns void


Private Method Details

addControl

private void addControl( string $name, object CControl $control )

  Adds the control.
First the control is checked on null. If the name is string then control is associated with this name. Otherwise, the name field of control is used. Otherwise, the control is added to the end of the list.

Parameter
string $name
- name of the control.
object CControl $control
- the control.
Returns void


getValue

private mixed getValue( object CControl $control )

  Returns value from the specified control.
Use this to override the data handling, e.g. to process special data formats.

Parameter
object CControl $control
Returns mixed

- value.


inValue

private mixed inValue( object CControl $control, mixed $value )

  Control's value to input to form.
Use this to override the data handling, e.g. to process special data formats.

Parameter
object CControl $control
mixed $value
- value.
Returns mixed

- in value.


outValue

private mixed outValue( object CControl $control )

  Control's value to output from the form.
Use this to override the data handling, e.g. to process special data formats.

Parameter
object CControl $control
Returns mixed

- out value.


outValues

private array outValues( )

  Collects output values of the form.
Use this to get form data as array.

Returns array

- out values.


validateValue

private mixed validateValue( object CControl $control )

  Use this to override the data verification on the form level,
e.g. to process special data formats.

Parameter
object CControl $control
Returns mixed

- control validation result.


renderStart

private void renderStart( )

  Use this to insert the form caption manually
and/or to override the method.

Returns void


renderEnd

private void renderEnd( )

  Use this to insert the form ending manually
and/or to override the method.

Returns void


renderStartControl

private void renderStartControl( &$control )

  Use this to insert the control prefix (e.g. label) manually
$form->renderStartControl($form->controls["name"]);
and/or to override the method.

Parameter
&$control
No additional comments.
Returns void


renderEndControl

private void renderEndControl( &$control )

  Use this to insert the control ending manually
$form->renderEndControl($form->controls["name"]);
and/or to override the method.

Parameter
&$control
No additional comments.
Returns void


write

private void write( $s )

  Just 'echoes' the string by default.
Use it to override this default behavior, e.g. to redirect output to file.

No additional comments.

Parameter
$s
No additional comments.
Returns void


Private Field Details

$mode

private string $mode

>>""<<

Form mode.
The additional mode supported by the form core is Readonly.

See Also setMode()

$action

private unknown $action

>><<

Form action. *


$method

private unknown $method

>><<

Form method.
GET, POST. *


$controls

private unknown $controls

>><<



Private Constant Details

NO_INDEX

define( NO_INDEX, >>-1<< )
Case: default: case sensitive


See Also addControl()


Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta