Returns rendered HTML form. Tables are used to place form elements.

category Formagic
package Renderer
author Florian Sonnenburg
copyright Copyright (c) 2007-2011 Florian Sonnenburg
version $Id: Html.php 169 2012-05-06 20:16:16Z meweasle $

 Methods

Sets the translator object for this renderer instance

__construct(Formagic_Translator $translator) 

Parameters

$translator

\Formagic_Translator

Translator instance

Returns container label template.

getContainerLabelTemplate(string | \Formagic_Item_Container $container) : string

Parameters

$container

string\Formagic_Item_Container

Optional. Returns a template defined for one specific container.

Returns

stringTemplate string

Returns the template for rows that hold sub-containers.

getContainerRowTemplate(string | \Formagic_Item_Container $container) : string

Parameters

$container

string\Formagic_Item_Container

Optional. Returns a template defined for one specific container.

Returns

stringTemplate string

Returns wrapper template for containers.

getContainerWrapperTemplate(string $container) : string

Parameters

$container

string

Optional. Returns a template defined for one specific item with name $name.

Returns

stringTemplate string

Returns form wrapper tag.

getFormWrapperTemplate() : string

Returns

stringTemplate string

Returns single error message template

getItemErrorTemplate(string | \Formagic_Item_Abstract $item) : string

Parameters

$item

string\Formagic_Item_Abstract

Optional. Returns a template defined for one specific item.

Returns

stringTemplate string

Returns error wrapper template for item errors.

getItemErrorWrapperTemplate(string | \Formagic_Item_Abstract $item) : string

Parameters

$item

string\Formagic_Item_Abstract

Optional. Returns a template defined for one specific item.

Returns

stringTemplate string

Returns label template for an item.

getItemLabelTemplate(string | \Formagic_Item_Abstract $item) : string

Parameters

$item

string\Formagic_Item_Abstract

Optional. Returns a template defined for one specific item.

Returns

stringTemplate string

Returns item row template.

getItemRowTemplate(string | \Formagic_Item_Abstract $item) : string

Parameters

$item

string\Formagic_Item_Abstract

Optional. Returns a template defined for one specific item.

Returns

stringTemplate string

Returns marker string for items marked as mandatory.

getMandatoryMarkerTemplate(string | \Formagic_Item_Abstract $item) : string

Parameters

$item

string\Formagic_Item_Abstract

Optional. Returns a template defined for one specific item.

Returns

stringTemplate string

Returns current translator instance.

getTranslator() : \Formagic_Translator

Returns

\Formagic_TranslatorTranslator object

Returns form HTML string

render(Formagic $form) : string

Parameters

$form

\Formagic

Formagic object to be rendered.

Returns

stringThe rendered HTML string

Sets container label template (empty by default).

setContainerLabelTemplate(string $template, string | \Formagic_Item_Container $container) : \Formagic_Renderer_Html

Available placeholders: - %LABEL%: Label string

see \setContainerWrapperTemplate()
see \setContainerRowTemplate()

Parameters

$template

string

Template string

$container

string\Formagic_Item_Container

Optional. Defines this template only for a specific container (name or container object).

Returns

\Formagic_Renderer_HtmlFluent interface

Sets new template for rows that hold sub-containers (tr/td tags by default).

setContainerRowTemplate(string $template, string | \Formagic_Item_Container $container) : \Formagic_Renderer_Html

Supported placeholders: - %CONTAINER%: HTML for the subcontainer, including it's wrapper

see \setContainerLabelTemplate()
see \setContainerWrapperTemplate()

Parameters

$template

string

Template string

$container

string\Formagic_Item_Container

Optional. Defines this template only for a specific container.

Returns

\Formagic_Renderer_HtmlFluent interface

Sets wrapper template for containers (opening/closing table tag by default).

setContainerWrapperTemplate(string $template, string | \Formagic_Item_Container $container) : \Formagic_Renderer_Html

Available placeholders: - %ROWS%: Rendered rows as HTML, including row wrapper - %ATTRIBUTES%: Assembled attributes string as HTML - %LABEL%: Rendered container label as HTML

see \setContainerLabelTemplate()
see \setContainerRowTemplate()

Parameters

$template

string

Template string

$container

string\Formagic_Item_Container

Optional. Defines this template only for a specific container.

Returns

\Formagic_Renderer_HtmlFluent interface

Sets error CSS class.

setErrorClass(string $errorClass) : \Formagic_Renderer_Html

This css class is per default added to the label and error list tag of items that did not pass validation.

Parameters

$errorClass

string

New error class

Returns

\Formagic_Renderer_HtmlFluent interface

Sets form wrapper template (opening/closing form tag by default).

setFormWrapperTemplate(string $template) : \Formagic_Renderer_Html

Available placeholders: - %ACTION%: Form action string - %METHOD%: Form method string - %ATTRIBUTES%: Assembled tag attributes string - %HIDDENS%: Rendered hidden inputs - %CONTAINER%: Rendered HTML of item holder container

Parameters

$template

string

Template string

Returns

\Formagic_Renderer_HtmlFluent interface

Sets a new template for a single error message (HTML LI tag by default)

setItemErrorTemplate(string $template, string | \Formagic_Item_Abstract $item) : \Formagic_Renderer_Html

Available placeholders: - %ERRORMESSAGE%: Message string returned by violated rule

Parameters

$template

string

Template string

$item

string\Formagic_Item_Abstract

Optional. Defines this template only for a specific item (name or item object).

Returns

\Formagic_Renderer_HtmlFluent interface

Sets error wrapper template (opening and closing list tags by default).

setItemErrorWrapperTemplate(string $template, string | \Formagic_Item_Abstract $item) : \Formagic_Renderer_Html

Supported placeholders: - %ERRORS%: Rendered list of item errors

Parameters

$template

string

Template string

$item

string\Formagic_Item_Abstract

Optional. Defines this template only for a specific item (name or item object).

Returns

\Formagic_Renderer_HtmlFluent interface

Sets label template for a single item (label tag by default).

setItemLabelTemplate(string $template, string | \Formagic_Item_Abstract $item) : \Formagic_Renderer_Html

Available placeholders: - %LABEL%: Label string defined for item - %ID%: Value of Item's HTML ID attribute - %MANDATORYMARKER%: Marker for items with mandatory rule

see \setItemRowTemplate()

Parameters

$template

string

Template string

$item

string\Formagic_Item_Abstract

Optional. Defines this template only for a specific item (name or item object).

Returns

\Formagic_Renderer_HtmlFluent interface

Sets template for rows containing input items (tr/td tags by default).

setItemRowTemplate(string $template, string | \Formagic_Item_Abstract $item) : \Formagic_Renderer_Html

Available placeholders: - %LABEL%: Item label string - %ERROR%: Assembled error list (HTML) - %ERRORCLASS%: CSS class attribute with error class (eg. ' class="formagicError"') - %INPUT%: Input HTML

see \setItemLabelTemplate()
see \setItemErrorTemplate()

Parameters

$template

string

Template string

$item

string\Formagic_Item_Abstract

Optional. Defines this template only for a specific item (name or item object).

Returns

\Formagic_Renderer_HtmlFluent interface

Sets marker string for items that are marked mandatory (asterisk by default).

setMandatoryMarkerTemplate(string $template, string | \Formagic_Item_Abstract $item) : \Formagic_Renderer_Html

Parameters

$template

string

Template string

$item

string\Formagic_Item_Abstract

Optional. Item this template is to be defined for.

Returns

\Formagic_Renderer_HtmlFluent interface

Adds hidden fields to form HTML string.

_addHiddenItem(Formagic_Item_Hidden $item) 

Parameters

$item

\Formagic_Item_Hidden

Hidden item to be rendered.

Renders a container label into the container label template.

_getContainerLabel(Formagic_Item_Container $container) : string

Returns empty string if no container label is defined.

Parameters

$container

\Formagic_Item_Container

Container item

Returns

stringContainer label and template string

Returns the rendered error list and HTML class attribute.

_getErrorProperties(Formagic_Item_Abstract $item) : array

Returns empty array if item validated ok.

Parameters

Returns

arrayError list and class attribute. Example: array( '
  • Please enter a value.
', ' class="formagicError"')

Returns rendered item label and template.

_getItemLabel(Formagic_Item_Abstract $item) : string

Returns a non-breakin-space HTML entity if no item label is provided.

Parameters

$item

\Formagic_Item_Abstract

Input item

Returns

stringItem label and template

Returns HTML for all items of a container (recursively)

_renderContainer(Formagic_Item_Container $container) : string

Parameters

$container

\Formagic_Item_Container

Container to be rendererd

Returns

stringHTML string

Sets a template string for an item to a template pool.

_setTemplate(array $templateArray, string $template, string | \Formagic_Item_Abstract $item) 

Parameters

$templateArray

array

Template pool new template is to be added to

$template

string

New template string

Returns a template for a specific item from a template array.

_getTemplate(array $templateArray, string | \Formagic_Item_Abstract $item) : string

Parameters

$templateArray

array

Pool of templates to choose from.

Returns

stringTemplate string

 Properties

 

Container label template array

$_containerLabelTemplate : array

 

Template for rows containing containers

$_containerRowTemplate : array

 

Container wrapping template array

$_containerWrapperTemplate : array

 

Error class name

$_errorClass : string

 

Form wrapping template array

$_formWrapperTemplate : array

 

Hidden inputs string

$_hiddenString : string

 

Array of templates for displaying the item error string (list elements)

$_itemErrorTemplate : array

 

Array of templates for item's error wrapper (list open tag)

$_itemErrorWrapperTemplate : array

 

Template for displaying the item label array

$_itemLabelTemplate : array

 

Template for rows containing normal items array

$_itemRowTemplate : array

 

HTML string for mandatory fields array

$_mandatoryMarkerTemplate : array

 

Translator object

$_translator : \Formagic_Translator