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

Class: HTML_QuickForm_Renderer_ArraySmarty

Source Location: /main/inc/lib/pear/HTML/QuickForm/Renderer/ArraySmarty.php

Class Overview

HTML_QuickForm_Renderer
   |
   --HTML_QuickForm_Renderer_Array
      |
      --HTML_QuickForm_Renderer_ArraySmarty

A static renderer for HTML_QuickForm, makes an array of form content useful for an Smarty template


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm_Renderer_Array

HTML_QuickForm_Renderer_Array::HTML_QuickForm_Renderer_Array()
Constructor
HTML_QuickForm_Renderer_Array::finishGroup()
HTML_QuickForm_Renderer_Array::renderElement()
HTML_QuickForm_Renderer_Array::renderHeader()
HTML_QuickForm_Renderer_Array::renderHidden()
HTML_QuickForm_Renderer_Array::setElementStyle()
Sets a style to use for element rendering
HTML_QuickForm_Renderer_Array::startForm()
HTML_QuickForm_Renderer_Array::startGroup()
HTML_QuickForm_Renderer_Array::toArray()
Returns the resultant array
HTML_QuickForm_Renderer_Array::_elementToArray()
Creates an array representing an element
HTML_QuickForm_Renderer_Array::_storeArray()
Stores an array representation of an element in the form array

Class: HTML_QuickForm_Renderer

HTML_QuickForm_Renderer::HTML_QuickForm_Renderer()
Constructor
HTML_QuickForm_Renderer::finishForm()
Called when visiting a form, after processing all form elements
HTML_QuickForm_Renderer::finishGroup()
Called when visiting a group, after processing all group elements
HTML_QuickForm_Renderer::renderElement()
Called when visiting an element
HTML_QuickForm_Renderer::renderHeader()
Called when visiting a header element
HTML_QuickForm_Renderer::renderHidden()
Called when visiting a hidden element
HTML_QuickForm_Renderer::renderHtml()
Called when visiting a raw HTML/text pseudo-element
HTML_QuickForm_Renderer::startForm()
Called when visiting a form, before processing any form elements
HTML_QuickForm_Renderer::startGroup()
Called when visiting a group, before processing any group elements

Class Details

[line 76]
A static renderer for HTML_QuickForm, makes an array of form content useful for an Smarty template

Based on old toArray() code and ITStatic renderer.

The form array structure is the following: Array ( [frozen] => whether the complete form is frozen' [javascript] => javascript for client-side validation [attributes] => attributes for <form> tag [hidden] => html of all hidden elements [requirednote] => note about the required elements [errors] => Array ( [1st_element_name] => Error for the 1st element ... [nth_element_name] => Error for the nth element )

[header] => Array ( [1st_header_name] => Header text for the 1st header ... [nth_header_name] => Header text for the nth header )

[1st_element_name] => Array for the 1st element ... [nth_element_name] => Array for the nth element

// where an element array has the form: ( [name] => element name [value] => element value, [type] => type of the element [frozen] => whether element is frozen [label] => label for the element [required] => whether element is required // if element is not a group: [html] => HTML for the element // if element is a group: [separator] => separator for group elements [1st_gitem_name] => Array for the 1st element in group ... [nth_gitem_name] => Array for the nth element in group ) )




Tags:

author:  Alexey Borzov <borz_off@cs.msu.su>
access:  public


[ Top ]


Class Variables

$_elementIdx =  0

[line 88]

Current element index


Type:   integer


[ Top ]

$_error =  ''

[line 108]

How to handle error messages in form validation



Tags:


Type:   string


[ Top ]

$_groupElementIdx =  0

[line 94]

The current element index inside a group


Type:   integer


[ Top ]

$_required =  ''

[line 101]

How to handle the required tag for required fields



Tags:


Type:   string


[ Top ]

$_tpl =  null

[line 82]

The Smarty template engine instance


Type:   object


[ Top ]



Class Methods


constructor HTML_QuickForm_Renderer_ArraySmarty [line 117]

HTML_QuickForm_Renderer_ArraySmarty HTML_QuickForm_Renderer_ArraySmarty( object reference &$tpl, [bool $staticLabels = false])

Constructor



Tags:

access:  public


Parameters:

object reference   &$tpl   to the Smarty template engine instance
bool   $staticLabels   true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key"

[ Top ]

method renderHeader [line 130]

void renderHeader( object An &$header)

Called when visiting a header element



Tags:

access:  public


Overrides HTML_QuickForm_Renderer_Array::renderHeader() (parent method not documented)

Parameters:

object An   &$header   HTML_QuickForm_header element being visited

[ Top ]

method setErrorTemplate [line 376]

void setErrorTemplate( string $template)

Sets the way elements with validation errors are rendered

You can use {$label} or {$html} placeholders to let the renderer know where where the element label or the element html are positionned according to the error message. They will be replaced accordingly with the right value. The error message will replace the {$error} placeholder. For example: {if $error}<span style="color: red;">{$error}</span>{/if}
{$html} will put the error message in red on top of the element html.

If you want all error messages to be output in the main error block, use the {$form.errors} part of the rendered array that collects all raw error messages.

If you want to place all error messages manually, do not specify {$html} nor {$label}.

Groups can have special layouts. With this kind of groups, you have to place the formated error message manually. In this case, use {$form.group.error} where you want the formated error message to appear in the form.




Tags:

access:  public


Parameters:

string   $template   The element error template

[ Top ]

method setRequiredTemplate [line 345]

void setRequiredTemplate( string $template)

Sets the way required elements are rendered

You can use {$label} or {$html} placeholders to let the renderer know where where the element label or the element html are positionned according to the required tag. They will be replaced accordingly with the right value. You can use the full smarty syntax here, especially a custom modifier for I18N. For example: {if $required}<span style="color: red;">*</span>{/if}{$label|translate} will put a red star in front of the label if the element is required and translate the label.




Tags:

access:  public


Parameters:

string   $template   The required element template

[ Top ]

method startGroup [line 149]

void startGroup( object An &$group, bool $required, string $error)

Called when visiting a group, before processing any group elements



Tags:

access:  public


Overrides HTML_QuickForm_Renderer_Array::startGroup() (parent method not documented)

Parameters:

object An   &$group   HTML_QuickForm_group object being visited
bool   $required   Whether a group is required
string   $error   An error message associated with a group

[ Top ]

method _elementToArray [line 165]

array _elementToArray( object An &$element, bool $required, string $error)

Creates an array representing an element containing the key for storing this



Tags:

access:  private


Overrides HTML_QuickForm_Renderer_Array::_elementToArray() (Creates an array representing an element)

Parameters:

object An   &$element   HTML_QuickForm_element object
bool   $required   Whether an element is required
string   $error   Error associated with the element

[ Top ]

method _renderError [line 296]

void _renderError( string &$label, string &$html, string &$error)

Called when an element has a validation error

This method will add the error message to the element label or the element html such as defined with the method setErrorTemplate. If the error placeholder is not found in the template, the error will be displayed in the form error block.




Tags:



Parameters:

string   &$label   The element label
string   &$html   The element html rendering
string   &$error   The element error

[ Top ]

method _renderRequired [line 265]

void _renderRequired( string &$label, string &$html, boolean &$required, string &$error)

Called when an element is required

This method will add the required tag to the element label and/or the element html such as defined with the method setRequiredTemplate.




Tags:



Parameters:

string   &$label   The element label
string   &$html   The element html rendering
boolean   &$required   The element required
string   &$error   The element error

[ Top ]

method _storeArray [line 235]

void _storeArray( array $elAry)

Stores an array representation of an element in the form array



Tags:

access:  private


Overrides HTML_QuickForm_Renderer_Array::_storeArray() (Stores an array representation of an element in the form array)

Parameters:

array   $elAry   Array representation of an element

[ Top ]

method _tplFetch [line 320]

void _tplFetch( string $tplSource)

Process an template sourced in a string with Smarty

Smarty has no core function to render a template given as a string. So we use the smarty eval plugin function to do this.




Tags:

access:  private


Parameters:

string   $tplSource   The template source

[ Top ]


Documentation generated on Thu, 12 Jun 2008 12:59:22 -0500 by phpDocumentor 1.4.1