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

Class: HTML_QuickForm_Renderer_ArraySmarty

Source Location: /HTML_QuickForm-3.2.14/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 a Smarty template


Author(s):

Version:

  • Release: 3.2.14

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

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 93]
A static renderer for HTML_QuickForm, makes an array of form content useful for a Smarty template

Based on old HTML_QuickForm::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 
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
      )
 )



[ Top ]


Method Detail

HTML_QuickForm_Renderer_ArraySmarty (Constructor)   [line 139]

HTML_QuickForm_Renderer_ArraySmarty HTML_QuickForm_Renderer_ArraySmarty( Smarty &$tpl, [bool $staticLabels = false], [bool $collectHidden = true])

Constructor
  • Access: public

Parameters:

Smarty   &$tpl   —  reference 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"
bool   $collectHidden   —  true: collect all hidden elements into string; false: process them as usual form elements

[ Top ]

renderHeader   [line 152]

void renderHeader( HTML_QuickForm_header &$header)

Called when visiting a header element
  • Access: public

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

Parameters:

HTML_QuickForm_header   &$header   —  header element being visited

[ Top ]

setErrorTemplate   [line 398]

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.

  • Access: public

Parameters:

string   $template   —  The element error template

[ Top ]

setRequiredTemplate   [line 367]

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.

  • Access: public

Parameters:

string   $template   —  The required element template

[ Top ]

startGroup   [line 171]

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

Called when visiting a group, before processing any group elements
  • Access: public

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

Parameters:

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

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:59:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.