WACT_COMPONENT
[ class tree: WACT_COMPONENT ] [ index: WACT_COMPONENT ] [ all elements ]

Class: FormComponent

Source Location: /framework/template/components/form/form.inc.php

http://wact.sourceforge.net/index.php/FormComponent

Class Overview

Component
   |
   --TagComponent
      |
      --FormComponent

The FormComponent provide a runtime API for control the behavior of a form

Variables

Methods


Child classes:

FormSelectDateComponent
Runtime form:selectdate API
FormSelectTimeComponent
Runtime form:selecttime API

Inherited Variables

Inherited Methods

Class: TagComponent

TagComponent::getAttribute()
Returns the value of an attribute, given it's name
TagComponent::getCanonicalAttributeName()
returns the case-preserving, case-insensitive name of an attribute
TagComponent::getClientId()
Returns the value of the ID attribute
TagComponent::hasAttribute()
Check to see whether a named attribute exists
TagComponent::removeAttribute()
Remove an attribute from the list
TagComponent::renderAttributes()
Writes the contents of the attributes to the screen, using htmlspecialchars to convert entities in values.
TagComponent::setAttribute()
Sets an attribute

Class: Component

Component::addChild()
Adds a reference to a child component to this component, using it's ID attribute as the child array key
Component::findChild()
Returns a child component given it's ID.
Component::findChildByClass()
Returns the first child component matching the supplied WACT_TEMPLATE Component PHP class name
Component::findParentByClass()
Recursively searches through parents of this component searching for a given WACT_TEMPLATE component PHP class name
Component::getChild()
Same as find child, except raises error if child is not found
Component::getServerId()
Returns the ID of the component, as defined in the template tags ID attribute
Component::render()
Outputs the component, rendering any child components as well This method will only ever be called on components that support Dynamic rendering.
Component::setChildDataSource()
set the data source of a child component, or raise an error if the child is not found.

Class Details

The FormComponent provide a runtime API for control the behavior of a form

Class Variables


$ErrorList =

An ErrorList object
access:  private
Type:   ErrorList

$IsValid = TRUE

Switch to identify whether the form has errors or not
var:  TRUE means no errors
access:  private
Type:   boolean

$StateVars = array()

An indexed array of variable names used to build hidden form fields which are passed on in the next POST request
access:  private
Type:   array

$_datasource =

DataSource object that we delegate to
access:  private
Type:   array

Class Methods


method ensureDataSourceAvailable



void ensureDataSourceAvailable( )

API Tags:

access:  private

method findLabel

Finds the LabelComponent associated with a form field, allowing an error message to be displayed next to the field.

Called by this setErrors.



mixed &findLabel( string $FieldId, object &$Component)

API Tags:

return:  either a LabelComponent or false if not found
access:  private

Parameters:

string   $FieldId   server id of the form field where the error occurred
object   &$Component   component below which the LabelComponent can be found

method getDataSource

Return the DataSource (typically this is called for you by controllers)

implementing &getDataSource( )

API Tags:

return:  DataSource
access:  public

method getErrorDataSet

Returns the ErrorList if it exists or an EmptyErrorList if not (typically this is called for you by controllers)

ErrorList &getErrorDataSet( )

API Tags:

return:  or EmptyErrorList
access:  public

method hasErrors

Determine whether the form has errors.

(typically this is called for you by controllers)



boolean hasErrors( )

API Tags:

return:  TRUE if the form has errros
access:  public

method prepare

Initializes the form DataSource (typically this is called for you by controllers)

void prepare( )

API Tags:

access:  public

method preserveState

Identify a property stored in the DataSource of the component, which should be passed as a hidden input field in the form post.

The name attribute of the hidden input field will be the name of the property. Use this to have properties persist between form submits



void preserveState( string $variable)

API Tags:

access:  public
see:  FormComponent::renderState()

Parameters:

string   $variable   name of property

method registerDataSource

Registers a DataSource with this component (typically this is called for you by controllers)

void registerDataSource( object &$datasource)

API Tags:

access:  public

Parameters:

object   &$datasource   implementing DataSource interface

method renderState

Renders the hidden fields for variables which should be preserved.

Called from within a compiled template render function.



void renderState( )

API Tags:

access:  public
see:  FormComponent::preserveState()
todo:  XHTML: Input fields should be closed

method setErrors

If errors occur, use this method to identify them to the FormComponent.

(typically this is called for you by controllers)



void setErrors( ErrorList &$ErrorList)

API Tags:

access:  public
see:  FormController

Parameters:

ErrorList   &$ErrorList  

method _getValue

Get the named property from the form DataSource

mixed _getValue( string $name)

API Tags:

return:  value or void if not found
deprecated:  will probablybe removed in a future reorganization of how form elements become associated with their values
access:  public

Parameters:

string   $name   variable name

method _setValue

Set a named property in the form DataSource

void _setValue( string $name, mixed $value)

API Tags:

deprecated:  will probablybe removed in a future reorganization of how form elements become associated with their values
access:  public

Parameters:

string   $name   variable name
mixed   $value   variable value
WACT: Copyright 2003 Procata, Inc. Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html)
Documentation generated on Sun, 28 Nov 2004 19:46:39 -0800 by phpDocumentor 1.2.3