TIP_Form

Introduction

Form generator

Source file
/Type/module/form.php
Extends
TIP_Module

Manages all the forms generated by the TIP system using the QuickForm PEAR package.

Properties

master : TIP_Content

A reference to the master content instance

access
protected

form_template : string

The file to run on form rendering

access
protected

action : TIP_FORM_ACTION_...

The type of action this form must perform

access
protected

json : boolean

Local flag to enable JSON on this form instance

access
protected

If left undefined, the global json flag (got from the TIP_Application instance) is used.

action_id : string

Action name

access
protected

Action identifier to use in localizing the title.

For basic actions, such as 'add', 'delete' and 'edit', you can leave it null: the value will default to the content of the 'action' property.

fields : array

An array of fields structures, as returned by TIP_Data::getFields()

access
protected

Setting this property you can choose the fields to manipulate. Leave it null for full automatic fields management.

readonly : array

An array of field ids to keep frozen

access
protected

captcha : boolean

Wheter to include a captcha element in the form

access
protected

buttons : int

A sum of TIP_FORM_BUTTON_... constants: leave it null to use default buttons regardling the requested action

access
protected

defaults : array

An associative array of explicit defaults provided by the application

access
protected

To this array, that initially will contain the defaults explicitely set in the configuration options or directly by the module, will be merged (with higher precedence) the default values provided by GETs.

fallbacks : array

An associative array of implicit defaults provided by the application

access
protected

This array provides the same information of the defaults property but using the implicit way. This means for immutable fields the form element will be preselected instead of be frozen.

Also the fallback values have lower precedence in the default assignment stack: if you provide both defaults and fallbacks, the latter value will not be used.

validation : string

Validation type, as described in HTML_QuickForm

access
protected

validator : callback

Validation callback

access
protected

Function to call before processing the data. It takes one argument: the associative array of values to validate. This callback must return true to process the record, or false to skip the processing.

This callback can be useful to provide additional validations (other than the ones provided by HTML_QuickForm) that need complex tasks.

on_process : callback

Process callback

access
protected

Function to call to process the data. This callback should take two arguments:

(usually the $this->_defaults array) or null

By default this callback is null. If the form needs to process the form and "on_process" is still undefined, an error is raised.

The return value must be %true on success or %false on error. Accordling to the return value, a notification message (error or info) will be generated.

invalid_render : TIP_FORM_RENDER_...

The render mode for not-validated form

access
protected

valid_render : TIP_FORM_RENDER_...

The render mode for validated form

access
protected

referer : string|null

The URI to follow on cancel

access
protected

Leaves it null to use the default referer. If the action is processed, all occurrences of {field} (where field is any valid field id) are expanded to their own value. If the action fails but this URI requires an expanded field, the default referer is used.

follower : string|null

The URI to chain up at the end of the action

access
protected

Leaves it null to use the default referer. If the action is processed, all occurrences of {field} (where field is any valid field id) are expanded to their own value. If the action fails but the URI requires an expanded field, the default referer is used.

notify_done : boolean

Whether to notify if an action exited succesfully

access
protected

text_cols : int

Default cols value for textarea items

access
protected

text_rows : int

Default rows value for textarea items

access
protected

Methods

checkOptions (&$options)

&$options
lines
230 - 269
static
yes
access
protected

__construct ($options)

Constructor

$options
array
Properties values
lines
278 - 282
access
protected

Initializes a TIP_Form instance.

run () : bool|null

Run the form

lines
296 - 303
access
public

Executes the requested action, accordling to the properties values set in the constructor.

validate () : bool|null

Define and validate the form

lines
311 - 320
access
public

validateAlso (&$module) : bool|null

Append a module structure to the current form and validate

&$module
TIP_Content
The module owning the structure to append
lines
329 - 364
access
public

process ()

Process the form

lines
372 - 410
access
public

Also resets the session stage counter on POST driven form to avoid multiple calls.

render ($valid) : bool

Render the form

$valid
bool|null
Whether the form was validated
lines
419 - 489
access
public

startView ($type) : &TIP_View|null

Start a form view

$type
string
The view type
lines
501 - 533
access
public

The available form views are: * 'SECTION' to browse throught the form sections

endView () : bool

End the current view

lines
539 - 547
access
public

getItem ($id) : mixed|null

Return the value of a generic item

$id
string
The item id
lines
560 - 573
access
public

Gets the value of a generic item. This implementation adds form specific features to the TIP_Module::getItem() method, such as the ability to get information from the current element or from the current section.

tagHidden ($params) : string|null

$params
string
Parameters of the tag
lines
583 - 589
access
protected

tagForm ($params) : string|null

$params
string
Parameters of the tag
lines
591 - 599
access
protected

tagSection ($params) : string|null

$params
string
Parameters of the tag
lines
601 - 614
access
protected

tagElement ($params) : string|null

Call an element method

$params
string
Parameters of the tag
lines
621 - 635
access
protected

Runs the method specified in $params on the current element.

TIP_Form was last modified by TiP on Mon 25 May 2009 06:22:25 PM CEST
Hosted by BerliOS Developer Logo