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

Class: HTML_QuickForm2_Renderer_Default

Source Location: /HTML_QuickForm2-2.1.0/HTML/QuickForm2/Renderer/Default.php

Class Overview

HTML_QuickForm2_Renderer
   |
   --HTML_QuickForm2_Renderer_Default

Default renderer for QuickForm2


Author(s):

Version:

  • Release: 2.1.0

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Renderer

HTML_QuickForm2_Renderer::__construct()
Constructor
HTML_QuickForm2_Renderer::exportMethods()
Returns an array of "published" method names that should be callable through proxy
HTML_QuickForm2_Renderer::factory()
Creates a new renderer instance of the given type
HTML_QuickForm2_Renderer::finishContainer()
Finishes rendering a generic container, called after processing contained elements
HTML_QuickForm2_Renderer::finishForm()
Finishes rendering a form, called after processing contained elements
HTML_QuickForm2_Renderer::finishGroup()
Finishes rendering a group, called after processing grouped elements
HTML_QuickForm2_Renderer::getJavascriptBuilder()
Returns the javascript builder object
HTML_QuickForm2_Renderer::getOption()
Returns the value(s) of the renderer option(s)
HTML_QuickForm2_Renderer::methodExists()
Checks whether a method is available in this object
HTML_QuickForm2_Renderer::register()
Registers a new renderer type
HTML_QuickForm2_Renderer::registerPlugin()
Registers a plugin for a renderer type
HTML_QuickForm2_Renderer::renderElement()
Renders a generic element
HTML_QuickForm2_Renderer::renderHidden()
Renders a hidden element
HTML_QuickForm2_Renderer::reset()
Resets the accumulated data
HTML_QuickForm2_Renderer::setJavascriptBuilder()
Sets the javascript builder object
HTML_QuickForm2_Renderer::setOption()
Sets the option(s) affecting renderer behaviour
HTML_QuickForm2_Renderer::startContainer()
Starts rendering a generic container, called before processing contained elements
HTML_QuickForm2_Renderer::startForm()
Starts rendering a form, called before processing contained elements
HTML_QuickForm2_Renderer::startGroup()
Starts rendering a group, called before processing grouped elements

Class Details

[line 51]
Default renderer for QuickForm2

Mostly a direct port of Default renderer from QuickForm 3.x package.

While almost everything in this class is defined as public, its properties and those methods that are not published (i.e. not in array returned by exportMethods()) will be available to renderer plugins only.

The following methods are published:



[ Top ]


Class Variables

$elementTemplatesForGroupClass = array(
        'html_quickform2_container' => array(
            'html_quickform2_element' => '{element}',
            'html_quickform2_container_fieldset' => '<fieldset{attributes}><qf:label><legend id="{id}-legend">{label}</legend></qf:label>{content}</fieldset>'
        ))

[line 108]

Default templates for elements in groups of the given classes

Array has the form ('group class' => ('element class' => 'template', ...), ...)

  • Access: public

Type:   array


[ Top ]

$elementTemplatesForGroupId = array()

[line 122]

Custom templates for grouped elements in the given group IDs

Array has the form ('group id' => ('element class' => 'template', ...), ...)

  • Access: public

Type:   array


[ Top ]

$errors = array()

[line 75]

Array of validation errors if 'group_errors' option is on
  • Access: public

Type:   array


[ Top ]

$groupId = array()

[line 128]

Array containing IDs of the groups being rendered
  • Access: public

Type:   array


[ Top ]

$hasRequired =  false

[line 57]

Whether the form contains required elements
  • Access: public

Type:   bool


[ Top ]

$hiddenHtml =  ''

[line 69]

HTML for hidden elements if 'group_hiddens' option is on
  • Access: public

Type:   string


[ Top ]

$html = array(array())

[line 63]

HTML generated for the form
  • Access: public

Type:   array


[ Top ]

$templatesForClass = array(
        'html_quickform2_element_inputhidden' => '<div style="display: none;">{element}</div>',
        'html_quickform2' => '<div class="quickform">{errors}<form{attributes}><div>{hidden}{content}</div></form><qf:reqnote><div class="reqnote">{reqnote}</div></qf:reqnote></div>',
        'html_quickform2_container_fieldset' => '<fieldset{attributes}><qf:label><legend id="{id}-legend">{label}</legend></qf:label>{content}</fieldset>',
        'special:error' => array(
            'prefix'    => '<div class="errors"><qf:message><p>{message}</p></qf:message><ul><li>',
            'separator' => '</li><li>',
            'suffix'    => '</li></ul><qf:message><p>{message}</p></qf:message></div>'
        ),'html_quickform2_element'=>'<div class="row"><p class="label"><qf:required><span class="required">*</span></qf:required><qf:label><label for="{id}">{label}</label></qf:label></p><div class="element<qf:error> error</qf:error>"><qf:error><span class="error">{error}<br /></span></qf:error>{element}</div></div>','html_quickform2_container_group'=>'<div class="row {class}"><p class="label"><qf:required><span class="required">*</span></qf:required><qf:label><label>{label}</label></qf:label></p><div class="element group<qf:error> error</qf:error>" id="{id}"><qf:error><span class="error">{error}<br /></span></qf:error>{content}</div></div>','html_quickform2_container_repeat'=>'<div class="row repeat" id="{id}"><qf:label><p>{label}</p></qf:label>{content}</div>')

[line 81]

Default templates for elements of the given class
  • Access: public

Type:   array


[ Top ]

$templatesForId = array()

[line 99]

Custom templates for elements with the given IDs
  • Access: public

Type:   array


[ Top ]



Method Detail

exportMethods   [line 130]

void exportMethods( )

  • Access: protected

Overrides HTML_QuickForm2_Renderer::exportMethods() (Returns an array of "published" method names that should be callable through proxy)
[ Top ]

findTemplate   [line 469]

string findTemplate( HTML_QuickForm2_Node $element, [string $default = '{element}'])

Finds a proper template for the element

Templates are scanned in a predefined order. First, if a template was set for a specific element by id, it is returned, no matter if the element belongs to a group. If the element does not belong to a group, we try to match a template using the element class. But, if the element belongs to a group, templates are first looked up using the containing group id, then using the containing group class. When no template is found, the provided default template is returned.

  • Return: Template
  • Access: public

Parameters:

HTML_QuickForm2_Node   $element   —  Element being rendered
string   $default   —  Default template to use if not found

[ Top ]

finishContainer   [line 308]

void finishContainer( HTML_QuickForm2_Node $container)

Finishes rendering a generic container, called after processing contained elements
  • Access: public

Overrides HTML_QuickForm2_Renderer::finishContainer() (Finishes rendering a generic container, called after processing contained elements)

Parameters:

HTML_QuickForm2_Node   $container   —  Container being rendered

[ Top ]

finishForm   [line 381]

void finishForm( HTML_QuickForm2_Node $form)

Finishes rendering a form, called after processing contained elements
  • Access: public

Overrides HTML_QuickForm2_Renderer::finishForm() (Finishes rendering a form, called after processing contained elements)

Parameters:

HTML_QuickForm2_Node   $form   —  Form being rendered

[ Top ]

finishGroup   [line 341]

void finishGroup( HTML_QuickForm2_Node $group)

Finishes rendering a group, called after processing grouped elements
  • Access: public

Overrides HTML_QuickForm2_Renderer::finishGroup() (Finishes rendering a group, called after processing grouped elements)

Parameters:

HTML_QuickForm2_Node   $group   —  Group being rendered

[ Top ]

markRequired   [line 532]

string markRequired( string $elTpl, bool $required)

Marks element required or removes "required" block
  • Return: Template with processed "required" block
  • Access: public

Parameters:

string   $elTpl   —  Element template
bool   $required   —  Whether element is required

[ Top ]

outputError   [line 553]

string outputError( string $elTpl, string $error)

Outputs element error, removes empty error blocks
  • Return: Template with error substitutions done
  • Access: public

Parameters:

string   $elTpl   —  Element template
string   $error   —  Validation error for the element

[ Top ]

outputGroupedErrors   [line 417]

string outputGroupedErrors( )

Creates a error list if 'group_errors' option is true
  • Return: HTML with a list of all validation errors
  • Access: public

[ Top ]

outputLabel   [line 577]

string outputLabel( string $elTpl, string|array $label)

Outputs element's label(s), removes empty label blocks
  • Return: Template with label substitutions done
  • Access: public

Parameters:

string   $elTpl   —  Element template
string|array   $label   —  Element label(s)

[ Top ]

prepareTemplate   [line 516]

string prepareTemplate( string $elTpl, HTML_QuickForm2_Node $element)

Processes the element's template, adding label(s), required note and error message
  • Return: Template with some substitutions done
  • Access: public

Parameters:

string   $elTpl   —  Element template
HTML_QuickForm2_Node   $element   —  Element being rendered

[ Top ]

renderElement   [line 268]

void renderElement( HTML_QuickForm2_Node $element)

Renders a generic element
  • Access: public

Overrides HTML_QuickForm2_Renderer::renderElement() (Renders a generic element)

Parameters:

HTML_QuickForm2_Node   $element   —  Element being rendered

[ Top ]

renderHidden   [line 281]

void renderHidden( HTML_QuickForm2_Node $element)

Renders a hidden element
  • Access: public

Overrides HTML_QuickForm2_Renderer::renderHidden() (Renders a hidden element)

Parameters:

HTML_QuickForm2_Node   $element   —  Hidden element being rendered

[ Top ]

reset   [line 241]

$this reset( )

Resets the accumulated data

This method is called automatically by startForm() method, but should be called manually before calling other rendering methods separately.

  • Access: public

Overrides HTML_QuickForm2_Renderer::reset() (Resets the accumulated data)
[ Top ]

setElementTemplateForGroupClass   [line 207]

$this setElementTemplateForGroupClass( string $groupClass, string $elementClass, mixed $template)

Sets grouped elements templates using group class

Templates set via setTemplateForClass() will not be used for grouped form elements. When searching for a template to use, the renderer will first consider template set for a specific group id, then the group templates set by group class.

  • Access: public

Parameters:

string   $groupClass   —  Group class name
string   $elementClass   —  Element class name
mixed   $template   —  Template

[ Top ]

setElementTemplateForGroupId   [line 227]

$this setElementTemplateForGroupId( string $groupId, string $elementClass, mixed $template)

Sets grouped elements templates using group id

Templates set via setTemplateForClass() will not be used for grouped form elements. When searching for a template to use, the renderer will first consider template set for a specific group id, then the group templates set by group class.

  • Access: public

Parameters:

string   $groupId   —  Group id
string   $elementClass   —  Element class name
mixed   $template   —  Template

[ Top ]

setErrorTemplate   [line 188]

$this setErrorTemplate( array $template)

Sets template for rendering validation errors

This template will be used if 'group_errors' option is set to true. The template array should contain 'prefix', 'suffix' and 'separator' keys.

  • Access: public

Parameters:

array   $template   —  Template for validation errors

[ Top ]

setTemplateForClass   [line 153]

$this setTemplateForClass( string $className, mixed $template)

Sets template for form elements that are instances of the given class

When searching for a template to use, renderer will check for templates set for element's class and its parent classes, until found. Thus a more specific template will override a more generic one.

  • Access: public

Parameters:

string   $className   —  Class name
mixed   $template   —  Template to use for elements of that class

[ Top ]

setTemplateForId   [line 171]

$this setTemplateForId( string $id, mixed $template)

Sets template for form element with the given id

If a template is set for an element via this method, it will be used. In the other case a generic template set by setTemplateForClass() or setElementTemplateForGroupClass() will be used.

  • Access: public

Parameters:

string   $id   —  Element's id
mixed   $template   —  Template to use for rendering of that element

[ Top ]

startContainer   [line 297]

void startContainer( HTML_QuickForm2_Node $container)

Starts rendering a generic container, called before processing contained elements
  • Access: public

Overrides HTML_QuickForm2_Renderer::startContainer() (Starts rendering a generic container, called before processing contained elements)

Parameters:

HTML_QuickForm2_Node   $container   —  Container being rendered

[ Top ]

startForm   [line 371]

void startForm( HTML_QuickForm2_Node $form)

Starts rendering a form, called before processing contained elements
  • Access: public

Overrides HTML_QuickForm2_Renderer::startForm() (Starts rendering a form, called before processing contained elements)

Parameters:

HTML_QuickForm2_Node   $form   —  Form being rendered

[ Top ]

startGroup   [line 330]

void startGroup( HTML_QuickForm2_Node $group)

Starts rendering a group, called before processing grouped elements
  • Access: public

Overrides HTML_QuickForm2_Renderer::startGroup() (Starts rendering a group, called before processing grouped elements)

Parameters:

HTML_QuickForm2_Node   $group   —  Group being rendered

[ Top ]

__toString   [line 257]

string __toString( )

Returns generated HTML
  • Access: public

[ Top ]


Documentation generated on Wed, 10 Apr 2019 08:56:08 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.