Skip to content

Phalcon html

NOTE

All classes are prefixed with Phalcon

Html\Attributes

Class Source on GitHub

This class helps to work with HTML Attributes

Uses Phalcon\Html\Attributes\RenderInterface · Phalcon\Html\Escaper\AttributeEscaper · Phalcon\Html\Exceptions\AttributeNotRenderable · Phalcon\Support\Collection

Method Summary

Methods

Public · 2

__toString()

public function __toString(): string;

Alias of the render method

render()

public function render(): string;

Render attributes as HTML attributes

Protected · 1

renderAttributes()

protected function renderAttributes( array $attributes ): string;

@todo remove this when we refactor forms. Maybe remove this class? Put it into traits

Html\Attributes\AttributesInterface

Interface Source on GitHub

Html Attributes Interface

  • Phalcon\Html\Attributes\AttributesInterface

Uses Phalcon\Html\Attributes

Method Summary

Methods

Public · 2

getAttributes()

public function getAttributes(): Attributes;

Get Attributes

setAttributes()

public function setAttributes( Attributes $attributes ): AttributesInterface;

Set Attributes

Html\Attributes\RenderInterface

Interface Source on GitHub

Rendering interface for HTML attributes

  • Phalcon\Html\Attributes\RenderInterface

Method Summary

Methods

Public · 1

render()

public function render(): string;

Generate a string representation

Html\Breadcrumbs

Class Source on GitHub

Phalcon\Html\Breadcrumbs

This component offers an easy way to create breadcrumbs for your application. The resulting HTML when calling render() will have each breadcrumb enclosed in <dt> tags, while the whole string is enclosed in <dl> tags.

  • Phalcon\Html\Breadcrumbs

Method Summary

Methods

Public · 7

add()

public function add(
    string $label,
    string $link = ""
): static;

Adds a new crumb.

// Adding a crumb with a link
$breadcrumbs->add("Home", "/");

// Adding a crumb without a link (normally the last one)
$breadcrumbs->add("Users");

Crumbs are stored keyed by their link, so adding two crumbs that share the same link - including two link-less crumbs, which share the empty string key - keeps only the last one.

clear()

public function clear(): void;

Clears the crumbs

$breadcrumbs->clear()

getSeparator()

public function getSeparator(): string;

Crumb separator

remove()

public function remove( string $link ): void;

Removes crumb by url.

$breadcrumbs->remove("/admin/user/create");

// remove a crumb without an url (last link)
$breadcrumbs->remove();

render()

public function render(): string;

Renders and outputs breadcrumbs based on previously set template.

echo $breadcrumbs->render();

setSeparator()

public function setSeparator( string $separator ): static;

toArray()

public function toArray(): array;

Returns the internal breadcrumbs array

Html\Escaper

Class Source on GitHub

Phalcon\Html\Escaper

Escapes different kinds of text securing them. By using this component you may prevent XSS attacks.

The class is a façade over five per-context escapers (HtmlEscaper, AttributeEscaper, CssEscaper, JsEscaper, UrlEscaper). Each can be retrieved via the matching getXxxEscaper() accessor and substituted via the matching setXxxEscaper() setter. The legacy setEncoding, setFlags, and setDoubleEncode continue to fan out to all sub-objects so existing code keeps working.

This component only works with UTF-8. The PREG extension needs to be compiled with UTF-8 support.

$escaper = new \Phalcon\Html\Escaper();

$escaped = $escaper->css("font-family: <Verdana>");

echo $escaped; // font\2D family\3A \20 \3C Verdana\3E

@property AttributeEscaper $attributeEscaper @property CssEscaper $cssEscaper @property HtmlEscaper $htmlEscaper @property JsEscaper $jsEscaper @property UrlEscaper $urlEscaper

Uses Phalcon\Html\Escaper\AttributeEscaper · Phalcon\Html\Escaper\CssEscaper · Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Escaper\HtmlEscaper · Phalcon\Html\Escaper\JsEscaper · Phalcon\Html\Escaper\UrlEscaper

Method Summary

public __construct(string $encoding = "utf-8",int $flags = 11,bool $doubleEncode = true) public string attributes( mixed $input = null ) Escapes a HTML attribute string or array. Delegates to the configured public string css( string $input ) Escape CSS strings. Delegates to the configured CssEscaper. public string|null detectEncoding( string $input ) public string escapeCss( string $input ) public string escapeHtml( string $input = null ) public string escapeHtmlAttr( string $input = null ) public string escapeJs( string $input ) public string escapeUrl( string $input ) public AttributeEscaper getAttributeEscaper() public CssEscaper getCssEscaper() public string getEncoding() public int getFlags() public HtmlEscaper getHtmlEscaper() public JsEscaper getJsEscaper() public UrlEscaper getUrlEscaper() public string html( string $input = null ) Escapes a HTML string. Delegates to the configured HtmlEscaper. public string js( string $input ) Escape javascript strings. Delegates to the configured JsEscaper. public string normalizeEncoding( string $input ) public static setAttributeEscaper( AttributeEscaper $escaper ) public static setCssEscaper( CssEscaper $escaper ) public static setDoubleEncode( bool $doubleEncode ) Sets the double_encode flag. Fans out to all sub-objects. public static setEncoding( string $encoding ) Sets the encoding. Fans out to all sub-objects. public static setFlags( int $flags ) Sets the htmlspecialchars flags. Fans out to all sub-objects. public static setHtmlEscaper( HtmlEscaper $escaper ) public static setHtmlQuoteType( int $flags ) public static setJsEscaper( JsEscaper $escaper ) public static setUrlEscaper( UrlEscaper $escaper ) public string url( string $input ) Escapes a URL. Delegates to the configured UrlEscaper.

Properties

protected AttributeEscaper $attributeEscaper
protected CssEscaper $cssEscaper
protected HtmlEscaper $htmlEscaper
protected JsEscaper $jsEscaper
protected UrlEscaper $urlEscaper

Methods

Public · 29

__construct()

public function __construct(
    string $encoding = "utf-8",
    int $flags = 11,
    bool $doubleEncode = true
);

attributes()

public function attributes( mixed $input = null ): string;

Escapes a HTML attribute string or array. Delegates to the configured AttributeEscaper.

css()

public function css( string $input ): string;

Escape CSS strings. Delegates to the configured CssEscaper.

detectEncoding()

final public function detectEncoding( string $input ): string|null;

escapeCss()

public function escapeCss( string $input ): string;

escapeHtml()

public function escapeHtml( string $input = null ): string;

escapeHtmlAttr()

public function escapeHtmlAttr( string $input = null ): string;

escapeJs()

public function escapeJs( string $input ): string;

escapeUrl()

public function escapeUrl( string $input ): string;

getAttributeEscaper()

public function getAttributeEscaper(): AttributeEscaper;

getCssEscaper()

public function getCssEscaper(): CssEscaper;

getEncoding()

public function getEncoding(): string;

getFlags()

public function getFlags(): int;

getHtmlEscaper()

public function getHtmlEscaper(): HtmlEscaper;

getJsEscaper()

public function getJsEscaper(): JsEscaper;

getUrlEscaper()

public function getUrlEscaper(): UrlEscaper;

html()

public function html( string $input = null ): string;

Escapes a HTML string. Delegates to the configured HtmlEscaper.

js()

public function js( string $input ): string;

Escape javascript strings. Delegates to the configured JsEscaper.

normalizeEncoding()

final public function normalizeEncoding( string $input ): string;

setAttributeEscaper()

public function setAttributeEscaper( AttributeEscaper $escaper ): static;

setCssEscaper()

public function setCssEscaper( CssEscaper $escaper ): static;

setDoubleEncode()

public function setDoubleEncode( bool $doubleEncode ): static;

Sets the double_encode flag. Fans out to all sub-objects.

setEncoding()

public function setEncoding( string $encoding ): static;

Sets the encoding. Fans out to all sub-objects.

setFlags()

public function setFlags( int $flags ): static;

Sets the htmlspecialchars flags. Fans out to all sub-objects.

setHtmlEscaper()

public function setHtmlEscaper( HtmlEscaper $escaper ): static;

setHtmlQuoteType()

public function setHtmlQuoteType( int $flags ): static;

setJsEscaper()

public function setJsEscaper( JsEscaper $escaper ): static;

setUrlEscaper()

public function setUrlEscaper( UrlEscaper $escaper ): static;

url()

public function url( string $input ): string;

Escapes a URL. Delegates to the configured UrlEscaper.

Html\EscaperFactory

Class Source on GitHub

Class EscaperFactory

  • Phalcon\Html\EscaperFactory

Method Summary

Methods

Public · 1

newInstance()

public function newInstance(): Escaper;

Create a new instance of the object

Html\Escaper\AbstractEscaper

Abstract Source on GitHub

Shared base for the per-context escaper objects. Holds the encoding, htmlspecialchars flag, and double-encode toggle, plus the encoding detection / normalization utilities used by the CSS and JS escapers.

Each concrete context (HtmlEscaper, AttributeEscaper, CssEscaper, JsEscaper, UrlEscaper) extends this so that callers can configure one context without affecting the others.

@property bool $doubleEncode @property string $encoding @property int $flags

Method Summary

Properties

protected bool $doubleEncode = true
protected string $encoding = "utf-8"
protected int $flags = 11 ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401

Methods

Public · 8

detectEncoding()

final public function detectEncoding( string $input ): string|null;

Detects the character encoding of a string. Special-handling for chr(172) and chr(128) to chr(159) which fail to be detected by mb_detect_encoding().

getDoubleEncode()

public function getDoubleEncode(): bool;

getEncoding()

public function getEncoding(): string;

getFlags()

public function getFlags(): int;

normalizeEncoding()

final public function normalizeEncoding( string $input ): string;

Normalizes a string's encoding to UTF-32, used by the CSS and JS escapers before invoking the C-level escape routines.

setDoubleEncode()

public function setDoubleEncode( bool $doubleEncode ): static;

setEncoding()

public function setEncoding( string $encoding ): static;

setFlags()

public function setFlags( int $flags ): static;

Html\Escaper\AttributeEscaper

Class Source on GitHub

Escapes either a single attribute value (string) or an associative array of attribute pairs. Boolean true becomes a bare key (e.g. disabled); false and null skip the entry; arrays are joined with a space.

Method Summary

Methods

Public · 2

__invoke()

public function __invoke( mixed $input = null ): string;

escape()

public function escape( mixed $input = null ): string;
Protected · 1

escapeValue()

protected function escapeValue( string $input ): string;

Encodes a single key/value via htmlspecialchars.

Html\Escaper\CssEscaper

Class Source on GitHub

Escapes a string for use inside a CSS value by replacing non-alphanumeric characters with their hexadecimal escape sequence.

Method Summary

Methods

Public · 2

__invoke()

public function __invoke( string $input ): string;

escape()

public function escape( string $input ): string;

Html\Escaper\EscaperInterface

Interface Source on GitHub

Interface for Phalcon\Html\Escaper.

This declares the stable context-escaping surface. The concrete {@see \Phalcon\Html\Escaper} facade also exposes members that are not part of this contract - setDoubleEncode(), getFlags(), and the per-context sub-escaper getters/setters (getHtmlEscaper(), setAttributeEscaper(), and the rest). Type against the concrete class to reach those.

  • Phalcon\Html\Escaper\EscaperInterface

Method Summary

Methods

Public · 8

attributes()

public function attributes( string $input ): string;

Escapes a HTML attribute string.

The concrete {@see \Phalcon\Html\Escaper} also accepts an array of attribute pairs and tolerates null: an array is rendered as escaped key="value" pairs, null and false values are skipped, and true renders as a bare key. Callers typed against this interface pass a string. The widened signature lands in the next major.

css()

public function css( string $input ): string;

Escape CSS strings by replacing non-alphanumeric chars by their hexadecimal representation

getEncoding()

public function getEncoding(): string;

Returns the internal encoding used by the escaper

html()

public function html( string $input ): string;

Escapes a HTML string.

The concrete {@see \Phalcon\Html\Escaper} tolerates null, returning an empty string for it. The nullable signature lands in the next major.

js()

public function js( string $input ): string;

Escape Javascript strings by replacing non-alphanumeric chars by their hexadecimal representation

setEncoding()

public function setEncoding( string $encoding ): EscaperInterface;

Sets the encoding to be used by the escaper

setFlags()

public function setFlags( int $flags ): EscaperInterface;

Sets the HTML quoting type for htmlspecialchars

url()

public function url( string $input ): string;

Escapes a URL. Internally uses rawurlencode

Html\Escaper\Exception

Class Source on GitHub

Class Exception

  • \Exception
    • Phalcon\Html\Escaper\Exception

Html\Escaper\HtmlEscaper

Class Source on GitHub

Escapes a string for use as HTML body content via htmlspecialchars.

Method Summary

Methods

Public · 2

__invoke()

public function __invoke( string $input = null ): string;

escape()

public function escape( string $input = null ): string;

Html\Escaper\JsEscaper

Class Source on GitHub

Escapes a string for use inside a JavaScript context by replacing non-alphanumeric characters with their hexadecimal escape sequence.

Method Summary

Methods

Public · 2

__invoke()

public function __invoke( string $input ): string;

escape()

public function escape( string $input ): string;

Html\Escaper\UrlEscaper

Class Source on GitHub

Escapes a string for use as a URL component via rawurlencode.

Method Summary

Methods

Public · 2

__invoke()

public function __invoke( string $input ): string;

escape()

public function escape( string $input ): string;

Html\Exception

Class Source on GitHub

Phalcon\Html\Exception

Exceptions thrown in Phalcon\Html will use this class

Html\Exceptions\AttributeNotRenderable

Class Source on GitHub

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct(
    string $key,
    string $type
);

Html\Exceptions\FriendlyTitleConversionFailed

Class Source on GitHub

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $message );

Html\Exceptions\InvalidResultsetValue

Class Source on GitHub

  • InvalidArgumentException
    • Phalcon\Html\Exceptions\InvalidResultsetValue

Uses InvalidArgumentException

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Html\Exceptions\ServiceNotRegistered

Class Source on GitHub

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

Html\Exceptions\UsingRequiresTwoValues

Class Source on GitHub

  • InvalidArgumentException
    • Phalcon\Html\Exceptions\UsingRequiresTwoValues

Uses InvalidArgumentException

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Html\Helper\AbstractHelper

Abstract Source on GitHub

@property string $delimiter @property EscaperInterface $escaper @property string $indent @property int $indentLevel

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Exception

Method Summary

Properties

protected string $delimiter = ""
protected Doctype|null $doctype = null
protected EscaperInterface $escaper
protected string $indent = " "
protected int $indentLevel = 1

Methods

Public · 1

__construct()

public function __construct(
    EscaperInterface $escaper,
    Doctype $doctype = null
);

AbstractHelper constructor.

Protected · 10

close()

protected function close(
    string $tag,
    bool $raw = false
): string;

Produces a closing tag

indent()

protected function indent(): string;

Replicates the indent x times as per indentLevel

injectAttribute()

protected function injectAttribute(
    string $key,
    string $value,
    array $attributes
): array;

Forces a single key into the attribute array, stripping any user-supplied value for that key first. Used by helpers whose first positional argument is itself an attribute (href for Anchor, src for Img, etc.) to make sure that argument always wins.

orderAttributes()

protected function orderAttributes(
    array $overrides,
    array $attributes
): array;

Keeps all the attributes sorted - same order all the time

renderArrayElements()

protected function renderArrayElements(
    array $elements,
    string $delimiter
): string;

Traverses an array and calls the method defined in the first element with attributes as the second, returning the resulting string

renderAttributes()

protected function renderAttributes( array $attributes ): string;

Renders all the attributes

renderElement()

protected function renderElement(
    string $tag,
    array $attributes = []
): string;

Renders an element

renderFullElement()

protected function renderFullElement(
    string $tag,
    string $text,
    array $attributes = [],
    bool $raw = false
): string;

Renders an element

renderTag()

protected function renderTag(
    string $tag,
    array $attributes = [],
    string $close = ""
): string;

Renders a tag

selfClose()

protected function selfClose(
    string $tag,
    array $attributes = []
): string;

Produces a self close tag i.e.

Html\Helper\AbstractList

Abstract Source on GitHub

Class AbstractList

Uses Phalcon\Html\Exception

Method Summary

Properties

protected array $attributes = []
protected string $elementTag = "li"
protected array $store = []

Methods

Public · 2

__invoke()

public function __invoke(
    string $indent = "    ",
    string $delimiter = null,
    array $attributes = []
): static;

__toString()

public function __toString();

Generates and returns the HTML for the list.

Protected · 1

getTag()

abstract protected function getTag(): string;

Returns the tag name.

Html\Helper\AbstractSeries

Abstract Source on GitHub

@property array $attributes @property array $store

Method Summary

Properties

protected array $attributes = []
protected array $store = []

Methods

Public · 3

__invoke()

public function __invoke(
    string $indent = "    ",
    string $delimiter = null
): static;

__toString()

public function __toString();

Generates and returns the HTML for the list. Entries are sorted by their integer key first, so an asset registered with a lower position renders before one registered with a higher position regardless of registration order.

reset()

public function reset(): static;

Resets the internal store.

Protected · 2

getTag()

abstract protected function getTag(): string;

Returns the tag name.

pushOrPlace()

protected function pushOrPlace(
    array $entry,
    int $position = -1
): void;

Appends an entry to the store, optionally at a specific integer position. When position is negative the entry is pushed onto the next available auto-increment slot. When position is non-negative the entry is placed at that key, advancing past any already-occupied slots so existing entries are not overwritten. The store is ksort()ed in __toString, so positions act as a sort key, not a strict address.

Html\Helper\Anchor

Class Source on GitHub

Class Anchor

@property bool $forceRaw

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Exception

Method Summary

Properties

protected bool $forceRaw = false

Methods

Public · 2

__construct()

public function __construct(
    EscaperInterface $escaper,
    Doctype $doctype = null,
    bool $forceRaw = false
);

__invoke()

public function __invoke(
    string $href,
    string $text,
    array $attributes = [],
    bool $raw = false
): string;

Produce a tag

Html\Helper\Base

Class Source on GitHub

Class Base

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $href = null,
    array $attributes = []
): string;

Produce a <base/> tag.

Html\Helper\Body

Class Source on GitHub

Class Body

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( array $attributes = [] ): string;

Produce a <body> tag.

Html\Helper\Breadcrumbs

Class Source on GitHub

This component offers an easy way to create breadcrumbs for your application. The resulting HTML when calling render() will have each breadcrumb enclosed in <li> tags, while the whole string is enclosed in <nav> and <ol> tags.

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Mvc\Url\UrlInterface · Phalcon\Support\Helper\Str\Interpolate

Method Summary

Methods

Public · 16

__construct()

public function __construct(
    EscaperInterface $escaper,
    UrlInterface $url = null
);

AbstractHelper constructor.

__invoke()

public function __invoke(
    string $indent = "    ",
    string $delimiter = null
): static;

Sets the indent and delimiter and returns the object back.

add()

public function add(
    string $text,
    string $link = "",
    string $icon = "",
    array $attributes = []
): static;

Adds a new crumb.

// Adding a crumb with a link
$breadcrumbs->add("Home", "/");

// Adding a crumb with added attributes
$breadcrumbs->add("Home", "/", ["class" => "main"]);

// Adding a crumb without a link (normally the last one)
$breadcrumbs->add("Users");

clear()

public function clear(): void;

Clears the crumbs.

$breadcrumbs->clear()

clearAttributes()

public function clearAttributes(): static;

Clear the attributes of the parent element.

getAttributes()

public function getAttributes(): array;

Get the attributes of the parent element.

getPrefix()

public function getPrefix(): string;

Returns the link prefix.

getSeparator()

public function getSeparator(): string;

Returns the separator.

getTemplate()

public function getTemplate(): array;

Return the current template.

remove()

public function remove( int $index ): void;

Removes crumb by url.

// Remove the second element
$breadcrumbs->remove(2);

render()

public function render(): string;

Renders and outputs breadcrumbs based on previously set template.

echo $breadcrumbs->render();

setAttributes()

public function setAttributes( array $attributes ): static;

Set the attributes for the parent element.

setPrefix()

public function setPrefix( string $prefix ): static;

Set the link prefix prepended to every non-empty link during rendering. When a Url service was injected, calling this method replaces it.

setSeparator()

public function setSeparator( string $separator ): static;

Set the separator.

setTemplate()

public function setTemplate(
    string $main,
    string $line,
    string $last
): static;

Set the HTML template.

toArray()

public function toArray(): array;

Returns the internal breadcrumbs array.

Html\Helper\Button

Class Source on GitHub

Class Button

@property bool $forceRaw

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Exception

Method Summary

Properties

protected bool $forceRaw = false

Methods

Public · 2

__construct()

public function __construct(
    EscaperInterface $escaper,
    Doctype $doctype = null,
    bool $forceRaw = false
);

__invoke()

public function __invoke(
    string $text,
    array $attributes = [],
    bool $raw = false
): string;

Produce a <button> tag.

Html\Helper\Close

Class Source on GitHub

Class Close

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $tag,
    bool $raw = false
): string;

Produce a </...> tag.

Html\Helper\Doctype

Class Source on GitHub

Creates Doctype tags

  • Phalcon\Html\Helper\Doctype

Method Summary

Constants

int HTML32 = 1
int HTML401_FRAMESET = 4
int HTML401_STRICT = 2
int HTML401_TRANSITIONAL = 3
int HTML5 = 5
int XHTML10_FRAMESET = 8
int XHTML10_STRICT = 6
int XHTML10_TRANSITIONAL = 7
int XHTML11 = 9
int XHTML20 = 10
int XHTML5 = 11

Methods

Public · 4

__construct()

public function __construct();

__invoke()

public function __invoke(
    int $type = self::HTML5,
    string $delimiter = "\n"
): static;

Produce a tag

__toString()

public function __toString(): string;

getType()

public function getType(): int;

Html\Helper\Element

Class Source on GitHub

Class Element

@property bool $forceRaw

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Exception

Method Summary

Properties

protected bool $forceRaw = false

Methods

Public · 2

__construct()

public function __construct(
    EscaperInterface $escaper,
    Doctype $doctype = null,
    bool $forceRaw = false
);

__invoke()

public function __invoke(
    string $tag,
    string $text,
    array $attributes = [],
    bool $raw = false
): string;

Produce a tag.

Html\Helper\Form

Class Source on GitHub

Class Form

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( array $attributes = [] ): string;

Produce a <form> tag.

Html\Helper\FriendlyTitle

Class Source on GitHub

Converts text to a URL-friendly slug.

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Exception · Phalcon\Html\Exceptions\FriendlyTitleConversionFailed · Phalcon\Support\Helper\Str\Friendly

Method Summary

Properties

protected Friendly $friendly

Methods

Public · 2

__construct()

public function __construct( EscaperInterface $escaper );

__invoke()

public function __invoke(
    string $text,
    string $separator = "-",
    bool $lowercase = true,
    mixed $replace = null
): string;

Html\Helper\Img

Class Source on GitHub

Class Img

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $src,
    array $attributes = []
): string;

Produce a tag.

Html\Helper\Input\AbstractChecked

Abstract Source on GitHub

Shared base for inputs that can be checked: <input type="checkbox"> and <input type="radio">. Holds the optional surrounding <label> markup, the unchecked companion hidden input, and the rule that decides whether the rendered tag carries checked="checked".

The match between checked and value is loose (==) by default so that mixed int/string form input round-trips correctly (e.g. value=0 against checked="0"). Strict (===) matching is available via strict(true).

@property array $label @property bool $strict

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Helper\Doctype

Method Summary

Properties

protected array $label = []
protected bool $strict = false

Methods

Public · 4

__construct()

public function __construct(
    EscaperInterface $escaper,
    Doctype $doctype = null
);

__toString()

public function __toString();

Returns the HTML for the input, optionally surrounded by the label fragment configured via label() and preceded by the hidden companion input emitted when an unchecked attribute is supplied.

label()

public function label( array $attributes = [] ): static;

Attaches a wrapping <label> to the element. The supplied attributes are merged with a default for pointing at the input's id. A text pseudo-attribute, if present, becomes the label text and is stripped from the rendered attributes.

strict()

public function strict( bool $flag = true ): static;

Toggles strict (===) comparison between the checked attribute and the value attribute when deciding whether to render the input as checked. Defaults to loose (==), which matches typical form-input round-tripping where types may differ between the source data and the value rendered into the markup.

Protected · 2

processChecked()

protected function processChecked(): void;

Decides whether the rendered tag carries checked="checked". Two paths qualify as checked: an unconditional opt-in via ["checked" => "checked"] (case-insensitive) or ["checked" => true], and a value-match path where the supplied checked attribute equals the input's value (== by default, === under strict(true)).

processUnchecked()

protected function processUnchecked(): string;

Returns the markup for the optional hidden companion input that lets a checkbox/radio submit a value when unchecked.

Html\Helper\Input\AbstractGroup

Abstract Source on GitHub

Shared base for rendering a group of same-named inputs (checkbox or radio) from an options array.

Each option in the $options array may be either: - a scalar string label: ['value' => 'Label text'] - a rich definition: ['value' => ['label' => 'Label text', 'disabled' => true, ...]]

The $checked parameter is resolved by the concrete subclass: - CheckboxGroup compares against an array of selected values - RadioGroup compares against a single scalar value

Uses Phalcon\Html\Helper\AbstractHelper

Method Summary

Properties

protected mixed $checked = null
protected string $name = ""
protected array $options = []
protected array $sharedAttributes = []
protected string $type = "checkbox"

Methods

Public · 2

__invoke()

public function __invoke(
    string $name,
    array $options,
    mixed $checked = null,
    array $attributes = []
): static;

__toString()

public function __toString(): string;

Renders the group of inputs as a string.

Protected · 2

isChecked()

abstract protected function isChecked( string $value ): bool;

Determines whether the given value is considered checked.

renderItem()

protected function renderItem(
    string $value,
    mixed $definition
): string;

Renders a single input + optional label pair.

Html\Helper\Input\AbstractInput

Abstract Source on GitHub

Class AbstractInput

@property array $attributes @property string $type @property string $value

Uses Phalcon\Html\Helper\AbstractHelper · Phalcon\Html\Helper\Doctype

Method Summary

Properties

protected array $attributes = []
protected string $type = "text"

Methods

Public · 3

__invoke()

public function __invoke(
    string $name,
    string $value = null,
    array $attributes = []
): static;

__toString()

public function __toString();

Returns the HTML for the input.

setValue()

public function setValue( string $value = null ): static;

Sets the value of the element

Html\Helper\Input\Checkbox

Class Source on GitHub

Renders an <input type="checkbox">. Behavior (label wrapping, unchecked companion, loose-by-default checked match) lives in AbstractChecked.

Properties

protected string $type = "checkbox"

Html\Helper\Input\CheckboxGroup

Class Source on GitHub

Renders a group of <input type="checkbox"> elements from an options array.

The $checked parameter should be an array of selected values, or a single scalar value (treated as a one-element array).

Method Summary

Properties

protected string $type = "checkbox"

Methods

Protected · 1

isChecked()

protected function isChecked( string $value ): bool;

Returns true when $value appears in the checked list.

Html\Helper\Input\Generic

Class Source on GitHub

Generic input helper. The HTML5 type attribute is supplied via the constructor, which means the TagFactory can register a single class for all type-string-only inputs (color, date, email, hidden, number, ...) and differentiate them through the recipe map. The type can also be changed after construction via setType().

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Helper\Doctype

Method Summary

Methods

Public · 2

__construct()

public function __construct(
    EscaperInterface $escaper,
    Doctype $doctype = null,
    string $type = "text"
);

setType()

public function setType( string $type ): AbstractInput;

Sets the type of the input.

Html\Helper\Input\Radio

Class Source on GitHub

Renders an <input type="radio">. Behavior (label wrapping, unchecked companion, loose-by-default checked match) lives in AbstractChecked.

Properties

protected string $type = "radio"

Html\Helper\Input\RadioGroup

Class Source on GitHub

Renders a group of <input type="radio"> elements from an options array.

The $checked parameter should be a single scalar value matching the selected option's value attribute.

Method Summary

Properties

protected string $type = "radio"

Methods

Protected · 1

isChecked()

protected function isChecked( string $value ): bool;

Returns true when $value loosely equals the checked scalar.

Html\Helper\Input\Select

Class Source on GitHub

Class Select

Uses Phalcon\Contracts\Html\Helper\Input\SelectData · Phalcon\Html\Helper\AbstractList

Method Summary

Properties

protected string $elementTag = "option"
protected bool $inOptGroup = false
protected string $selected = ""
protected bool $strict = false

Methods

Public · 7

add()

public function add(
    string $text,
    string $value = null,
    array $attributes = [],
    bool $raw = false
): static;

Add an element to the list

addPlaceholder()

public function addPlaceholder(
    string $text,
    string $value = null,
    array $attributes = [],
    bool $raw = false
): static;

Add a placeholder to the element

fromData()

public function fromData( SelectData $data ): static;

Populates the select from a data provider.

Flat entries: key = option value, value = label string. Optgroup entries: key = group label, value = [value => label] array.

optGroup()

public function optGroup(
    string $label = null,
    array $attributes = []
): static;

Creates an option group

placeholder()

public function placeholder( string $text ): static;

Adds a non-selectable placeholder option as the first entry. Renders as <option value="" disabled selected>$text</option>, matching the common HTML idiom for "Choose..."-style prompts.

selected()

public function selected( string $selected ): static;

strict()

public function strict( bool $flag = true ): static;

Toggles strict (===) comparison between an option's value and the previously stored selected value. Defaults to loose (==), matching the round-tripping fix in AbstractChecked so mixed int/string form data marks the right option as selected.

Protected · 3

getTag()

protected function getTag(): string;

optGroupEnd()

protected function optGroupEnd(): string;

optGroupStart()

protected function optGroupStart(
    string $label,
    array $attributes
): string;

Html\Helper\Input\Select\ArrayData

Class Source on GitHub

Wraps a plain PHP array as a SELECT data provider.

Keys are option values; string values are labels; array values define optgroups.

Uses Phalcon\Contracts\Html\Helper\Input\SelectData

Method Summary

Properties

protected array $attributes = []
protected array $data = []

Methods

Public · 3

__construct()

public function __construct(
    array $data = [],
    array $attributes = []
);

getAttributes()

public function getAttributes(): array;

getOptions()

public function getOptions(): array;

Html\Helper\Input\Select\ResultsetData

Class Source on GitHub

Uses InvalidArgumentException · Phalcon\Contracts\Html\Helper\Input\SelectData · Phalcon\Html\Exceptions\InvalidResultsetValue · Phalcon\Html\Exceptions\UsingRequiresTwoValues · Phalcon\Mvc\Model\ResultsetInterface

Method Summary

Properties

protected array $attributesMap = []
protected array|null $resolvedAttributes = null
protected array|null $resolvedOptions = null
protected ResultsetInterface $resultset
protected array $using = []

Methods

Public · 3

__construct()

public function __construct(
    ResultsetInterface $resultset,
    array $using,
    array $attributesMap = []
);

getAttributes()

public function getAttributes(): array;

Returns per-option attribute maps, keyed by option value.

getOptions()

public function getOptions(): array;
Protected · 2

readField()

protected function readField(
    mixed $option,
    string $field
);

Reads a property from the row, supporting both objects (via readAttribute when present) and plain arrays.

resolve()

protected function resolve(): void;

Walks the resultset once, building both the option map and the per-option resolved attribute map. Closures in attributesMap receive the current row; static values are passed through. false or null values skip the attribute entirely.

Html\Helper\Input\Textarea

Class Source on GitHub

Class Textarea

Uses Phalcon\Html\Exception

Method Summary

Properties

protected string $type = "textarea"

Methods

Public · 1

__toString()

public function __toString();

Returns the HTML for the input.

Html\Helper\Label

Class Source on GitHub

Class Label

@property bool $forceRaw

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Exception

Method Summary

Properties

protected bool $forceRaw = false

Methods

Public · 2

__construct()

public function __construct(
    EscaperInterface $escaper,
    Doctype $doctype = null,
    bool $forceRaw = false
);

__invoke()

public function __invoke(
    string $label,
    array $attributes = [],
    bool $raw = false
): string;

Produce a <label> tag.

Class Source on GitHub

Creates tags

Method Summary

Methods

Public · 1
public function add(
    string $url,
    array $attributes = [],
    int $position = -1
): static;

Add an element to the list

Protected · 2
protected function getAttributes(
    string $url,
    array $attributes
): array;

Returns the necessary attributes

protected function getTag(): string;

Html\Helper\Meta

Class Source on GitHub

Class Meta

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 4

add()

public function add(
    array $attributes = [],
    int $position = -1
): static;

Add an element to the list

addHttp()

public function addHttp(
    string $httpEquiv,
    string $content,
    int $position = -1
): static;

addName()

public function addName(
    string $name,
    string $content,
    int $position = -1
): static;

addProperty()

public function addProperty(
    string $name,
    string $content,
    int $position = -1
): static;
Protected · 1

getTag()

protected function getTag(): string;

Html\Helper\Ol

Class Source on GitHub

Class Ol

@property bool $forceRaw

Uses Phalcon\Html\Escaper\EscaperInterface

Method Summary

Properties

protected bool $forceRaw = false

Methods

Public · 2

__construct()

public function __construct(
    EscaperInterface $escaper,
    Doctype $doctype = null,
    bool $forceRaw = false
);

add()

public function add(
    string $text,
    array $attributes = [],
    bool $raw = false
): static;

Add an element to the list

Protected · 1

getTag()

protected function getTag(): string;

Html\Helper\Preload

Class Source on GitHub

Generates a tag for resource hinting. If a ResponseInterface is provided, also sets the HTTP Link header.

Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Link\Link · Phalcon\Html\Link\Serializer\Header · Phalcon\Http\ResponseInterface

Method Summary

Properties

protected ResponseInterface|null $response = null

Methods

Public · 2

__construct()

public function __construct(
    EscaperInterface $escaper,
    ResponseInterface $response = null
);

__invoke()

public function __invoke(
    string $href,
    string $type = "style",
    array $attributes = []
): string;

Html\Helper\Script

Class Source on GitHub

Class Script

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 3

add()

public function add(
    string $url,
    array $attributes = [],
    int $position = -1
): static;

Add an element to the list

beginInternal()

public function beginInternal(): void;

Begins capturing inline script content via output buffering. Pair with endInternal() to close the buffer and append the captured markup as a <script>...</script> block in the asset stack.

endInternal()

public function endInternal(
    array $attributes = [],
    int $position = -1
): static;

Closes an inline-script buffer opened by beginInternal() and adds the captured content as a <script>...</script> entry. Any attributes supplied are placed on the wrapping tag. The script body is treated as raw HTML (it is JavaScript, not user-supplied text).

Protected · 2

getAttributes()

protected function getAttributes(
    string $url,
    array $attributes
): array;

Returns the necessary attributes

getTag()

protected function getTag(): string;

Html\Helper\Style

Class Source on GitHub

Class Style

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 2

add()

public function add(
    string $url,
    array $attributes = [],
    int $position = -1
): static;

Add an element to the list

setStyle()

public function setStyle( bool $flag ): static;

Sets if this is a style or link tag

Protected · 2

getAttributes()

protected function getAttributes(
    string $url,
    array $attributes
): array;

Returns the necessary attributes

getTag()

protected function getTag(): string;

Html\Helper\Tag

Class Source on GitHub

Generic open-tag escape hatch. Renders just <name attr="..."> for any tag name without a dedicated helper. For an open + content + close tag use Element instead. For self-closing void tags (img, br, hr, etc.) use VoidTag.

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $name,
    array $attributes = []
): string;

Html\Helper\Title

Class Source on GitHub

Class Title

@property array $append @property string $delimiter @property string $indent @property array $prepend @property string $title @property string $separator

Uses Phalcon\Html\Exception

Method Summary

Properties

protected array $append = []
protected array $prepend = []
protected string $separator = ""
protected string $title = ""

Methods

Public · 7

__invoke()

public function __invoke(
    string $indent = "    ",
    string $delimiter = null
): static;

Sets the separator and returns the object back

__toString()

public function __toString();

Returns the title tags

append()

public function append(
    string $text,
    bool $raw = false
): static;

Appends text to current document title

get()

public function get(): string;

Returns the title

prepend()

public function prepend(
    string $text,
    bool $raw = false
): static;

Prepends text to current document title

set()

public function set(
    string $text,
    bool $raw = false
): static;

Sets the title

setSeparator()

public function setSeparator(
    string $separator,
    bool $raw = false
): static;

Sets the separator

Html\Helper\Ul

Class Source on GitHub

Class Ul

Method Summary

Methods

Protected · 1

getTag()

protected function getTag(): string;

Html\Helper\VoidTag

Class Source on GitHub

Generic void-tag escape hatch. Renders a self-closing tag for any name without a dedicated helper. The trailing / is emitted only for XHTML doctypes, matching the Input/AbstractInput::__toString convention.

Uses Phalcon\Html\Exception

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $name,
    array $attributes = []
): string;

Abstract Source on GitHub

@property Collection $attributes @property string $href @property Collection $rels @property bool $templated

Uses Phalcon\Support\Collection

Method Summary

Properties

protected Collection $attributes
protected string $href = ""
protected Collection $rels
protected bool $templated = false

Methods

Public · 1
public function __construct(
    string $rel = "",
    string $href = "",
    array $attributes = []
);

Link constructor.

Protected · 10
protected function doGetAttributes(): array;

Returns a list of attributes that describe the target URI.

protected function doGetHref(): string;

Returns the target of the link.

The target link must be one of: - An absolute URI, as defined by RFC 5988. - A relative URI, as defined by RFC 5988. The base of the relative link is assumed to be known based on context by the client. - A URI template as defined by RFC 6570.

If a URI template is returned, isTemplated() MUST return True.

protected function doGetRels(): array;

Returns the relationship type(s) of the link.

This method returns 0 or more relationship types for a link, expressed as an array of strings.

protected function doIsTemplated(): bool;

Returns whether this is a templated link.

protected function doWithAttribute(
    string $key,
    mixed $value
): static;
protected function doWithHref( string $href ): static;
protected function doWithRel( string $key ): static;
protected function doWithoutAttribute( string $key ): static;
protected function doWithoutRel( string $key ): static;
protected function hrefIsTemplated( string $href ): bool;

Determines if a href is a templated link or not.

@see https://tools.ietf.org/html/rfc6570

Html\Link\AbstractLinkProvider

Abstract Source on GitHub

@property array $links

Uses Phalcon\Html\Link\Interfaces\LinkInterface

Method Summary

Properties

protected array $links = []

Methods

Public · 1

__construct()

public function __construct( array $links = [] );

LinkProvider constructor.

Protected · 5
protected function doGetLinks(): array;

Returns an iterable of LinkInterface objects.

The iterable may be an array or any PHP \Traversable object. If no links are available, an empty array or \Traversable MUST be returned.

doGetLinksByRel()

protected function doGetLinksByRel( string $rel ): array;

Returns an iterable of LinkInterface objects that have a specific relationship.

The iterable may be an array or any PHP \Traversable object. If no links with that relationship are available, an empty array or \Traversable MUST be returned.

protected function doWithLink( mixed $link ): static;

Returns an instance with the specified link included.

If the specified link is already present, this method MUST return normally without errors. The link is present if $link is === identical to a link object already in the collection.

protected function doWithoutLink( mixed $link ): static;

Returns an instance with the specified link removed.

If the specified link is not present, this method MUST return normally without errors. The link is present if $link is === identical to a link object already in the collection.

getKey()

protected function getKey( mixed $link ): string;

Returns the object hash key

Class Source on GitHub

Class Phalcon\Html\Link\EvolvableLink

Uses Phalcon\Html\Link\Interfaces\EvolvableLinkInterface

Method Summary

Methods

Public · 5
public function withAttribute(
    mixed $attribute,
    mixed $value
): static;

Returns an instance with the specified attribute added.

If the specified attribute is already present, it will be overwritten with the new value.

public function withHref( string $href ): static;

Returns an instance with the specified href.

An implementing library SHOULD evaluate a passed object to a string immediately rather than waiting for it to be returned later.

public function withRel( string $rel ): static;

Returns an instance with the specified relationship included.

If the specified rel is already present, this method MUST return normally without errors, but without adding the rel a second time.

public function withoutAttribute( string $attribute ): static;

Returns an instance with the specified attribute excluded.

If the specified attribute is not present, this method MUST return normally without errors.

public function withoutRel( string $rel ): static;

Returns an instance with the specified relationship excluded.

If the specified rel is not present, this method MUST return normally without errors.

Html\Link\EvolvableLinkProvider

Class Source on GitHub

Class Phalcon\Html\Link\EvolvableLinkProvider

@property LinkInterface[] $links

Uses Phalcon\Html\Link\Interfaces\EvolvableLinkProviderInterface · Phalcon\Html\Link\Interfaces\LinkInterface

Method Summary

Methods

Public · 2
public function withLink( LinkInterface $link ): static;

Returns an instance with the specified link included.

If the specified link is already present, this method MUST return normally without errors. The link is present if link is === identical to a link object already in the collection.

public function withoutLink( LinkInterface $link ): static;

Returns an instance with the specified link removed.

If the specified link is not present, this method MUST return normally without errors. The link is present if link is === identical to a link object already in the collection.

Html\Link\Interfaces\EvolvableLinkInterface

Interface Source on GitHub

An evolvable link value object.

Method Summary

Methods

Public · 5

withAttribute()

public function withAttribute(
    string $attribute,
    string $value
): EvolvableLinkInterface;

Returns an instance with the specified attribute added.

If the specified attribute is already present, it will be overwritten with the new value.

withHref()

public function withHref( string $href ): EvolvableLinkInterface;

Returns an instance with the specified href.

An implementing library SHOULD evaluate a passed object to a string immediately rather than waiting for it to be returned later.

withRel()

public function withRel( string $rel ): EvolvableLinkInterface;

Returns an instance with the specified relationship included.

If the specified rel is already present, this method MUST return normally without errors, but without adding the rel a second time.

withoutAttribute()

public function withoutAttribute( string $attribute ): EvolvableLinkInterface;

Returns an instance with the specified attribute excluded.

If the specified attribute is not present, this method MUST return normally without errors.

withoutRel()

public function withoutRel( string $rel ): EvolvableLinkInterface;

Returns an instance with the specified relationship excluded.

If the specified rel is already not present, this method MUST return normally without errors.

Html\Link\Interfaces\EvolvableLinkProviderInterface

Interface Source on GitHub

An evolvable link provider value object.

Method Summary

Methods

Public · 2
public function withLink( LinkInterface $link ): EvolvableLinkProviderInterface;

Returns an instance with the specified link included.

If the specified link is already present, this method MUST return normally without errors. The link is present if $link is === identical to a link object already in the collection.

public function withoutLink( LinkInterface $link ): EvolvableLinkProviderInterface;

Returns an instance with the specified link removed.

If the specified link is not present, this method MUST return normally without errors. The link is present if $link is === identical to a link object already in the collection.

Html\Link\Interfaces\LinkInterface

Interface Source on GitHub

A readable link object.

Method Summary

Methods

Public · 4

getAttributes()

public function getAttributes(): array;

Returns a list of attributes that describe the target URI.

getHref()

public function getHref(): string;

Returns the target of the link.

The target link must be one of: - An absolute URI, as defined by RFC 5988. - A relative URI, as defined by RFC 5988. The base of the relative link is assumed to be known based on context by the client. - A URI template as defined by RFC 6570.

If a URI template is returned, isTemplated() MUST return True.

getRels()

public function getRels(): array;

Returns the relationship type(s) of the link.

This method returns 0 or more relationship types for a link, expressed as an array of strings.

isTemplated()

public function isTemplated(): bool;

Returns whether this is a templated link.

Html\Link\Interfaces\LinkProviderInterface

Interface Source on GitHub

A link provider object.

Method Summary

Methods

Public · 2
public function getLinks(): array;

Returns an array of LinkInterface objects.

getLinksByRel()

public function getLinksByRel( string $rel ): array;

Returns an array of LinkInterface objects that have a specific relationship.

Class Source on GitHub

Class Phalcon\Html\Link\Link

Uses Phalcon\Html\Link\Interfaces\LinkInterface

Method Summary

Methods

Public · 4
public function getAttributes(): array;

Returns a list of attributes that describe the target URI.

public function getHref(): string;

Returns the target of the link.

The target link must be one of: - An absolute URI, as defined by RFC 5988. - A relative URI, as defined by RFC 5988. The base of the relative link is assumed to be known based on context by the client. - A URI template as defined by RFC 6570.

If a URI template is returned, isTemplated() MUST return True.

public function getRels(): array;

Returns the relationship type(s) of the link.

This method returns 0 or more relationship types for a link, expressed as an array of strings.

public function isTemplated(): bool;

Returns whether or not this is a templated link.

Html\Link\LinkProvider

Class Source on GitHub

@property LinkInterface[] links

Uses Phalcon\Html\Link\Interfaces\LinkInterface · Phalcon\Html\Link\Interfaces\LinkProviderInterface

Method Summary

Methods

Public · 2
public function getLinks(): array;

Returns an iterable of LinkInterface objects.

The iterable may be an array or any PHP \Traversable object. If no links are available, an empty array or \Traversable MUST be returned.

getLinksByRel()

public function getLinksByRel( mixed $rel ): array;

Returns an iterable of LinkInterface objects that have a specific relationship.

The iterable may be an array or any PHP \Traversable object. If no links with that relationship are available, an empty array or \Traversable MUST be returned.

Html\Link\Serializer\Header

Class Source on GitHub

Class Phalcon\Http\Link\Serializer\Header

Method Summary

Methods

Public · 1

serialize()

public function serialize( array $links ): string|null;

Serializes all the passed links to a HTTP link header

Html\Link\Serializer\SerializerInterface

Interface Source on GitHub

Class Phalcon\Http\Link\Serializer\SerializerInterface

  • Phalcon\Html\Link\Serializer\SerializerInterface

Method Summary

Methods

Public · 1

serialize()

public function serialize( array $links ): string|null;

Serializer method

Html\TagFactory

Class Source on GitHub

ServiceLocator implementation for Tag helpers.

Built-in services are seeded by the constructor. Users may add or override services via set(), passing a Closure that returns the helper instance.

Helpers are cached per name after first construction.

@method string a(string $href, string $text, array $attributes = [], bool $raw = false) @method string aRaw(string $href, string $text, array $attributes = []) @method string base(string $href, array $attributes = []) @method string body(array $attributes = []) @method Breadcrumbs breadcrumbs(string $indent = ' ', string $delimiter = "\n") @method string button(string $text, array $attributes = [], bool $raw = false) @method string buttonRaw(string $text, array $attributes = []) @method string close(string $tag, bool $raw = false) @method Doctype doctype(int $type = Doctype::HTML5, string $delimiter = "\n") @method string element(string $tag, string $text, array $attributes = [], bool $raw = false) @method string elementRaw(string $tag, string $text, array $attributes = []) @method string form(array $attributes = []) @method string friendlyTitle(string $text, string $separator = '-', bool $lowercase = true, mixed $replace = null) @method string img(string $src, array $attributes = []) @method Checkbox inputCheckbox(string $name, string $value = null, array $attributes = []) @method CheckboxGroup inputCheckboxGroup(string $name, array $options, mixed $checked = null, array $attributes = []) @method Generic inputColor(string $name, string $value = null, array $attributes = []) @method Generic inputDate(string $name, string $value = null, array $attributes = []) @method Generic inputDateTime(string $name, string $value = null, array $attributes = []) @method Generic inputDateTimeLocal(string $name, string $value = null, array $attributes = []) @method Generic inputEmail(string $name, string $value = null, array $attributes = []) @method Generic inputFile(string $name, string $value = null, array $attributes = []) @method Generic inputHidden(string $name, string $value = null, array $attributes = []) @method Generic inputImage(string $name, string $value = null, array $attributes = []) @method Generic inputInput(string $name, string $value = null, array $attributes = []) @method Generic inputMonth(string $name, string $value = null, array $attributes = []) @method Generic inputNumeric(string $name, string $value = null, array $attributes = []) @method Generic inputPassword(string $name, string $value = null, array $attributes = []) @method Radio inputRadio(string $name, string $value = null, array $attributes = []) @method RadioGroup inputRadioGroup(string $name, array $options, mixed $checked = null, array $attributes = []) @method Generic inputRange(string $name, string $value = null, array $attributes = []) @method Generic inputSearch(string $name, string $value = null, array $attributes = []) @method Select inputSelect(string $name, string $value = null, array $attributes = []) @method Generic inputSubmit(string $name, string $value = null, array $attributes = []) @method Generic inputTel(string $name, string $value = null, array $attributes = []) @method Generic inputText(string $name, string $value = null, array $attributes = []) @method Textarea inputTextarea(string $name, string $value = null, array $attributes = []) @method Generic inputTime(string $name, string $value = null, array $attributes = []) @method Generic inputUrl(string $name, string $value = null, array $attributes = []) @method Generic inputWeek(string $name, string $value = null, array $attributes = []) @method string label(string $label, array $attributes = [], bool $raw = false) @method string labelRaw(string $label, array $attributes = []) @method Link link(string $indent = ' ', string $delimiter = "\n") @method Meta meta(string $indent = ' ', string $delimiter = "\n") @method Ol ol(string $indent = ' ', string $delimiter = null, array $attributes = []) @method Ol olRaw(string $indent = ' ', string $delimiter = null, array $attributes = []) @method string preload(string $href, string $type = 'style', array $attributes = []) @method Script script(string $indent = ' ', string $delimiter = "\n") @method Style style(string $indent = ' ', string $delimiter = "\n") @method string tag(string $name, array $attributes = []) @method Title title(string $indent = ' ', string $delimiter = "\n") @method Ul ul(string $indent = ' ', string $delimiter = null, array $attributes = []) @method Ul ulRaw(string $indent = ' ', string $delimiter = null, array $attributes = []) @method string voidTag(string $name, array $attributes = [])

  • Phalcon\Html\TagFactory

Uses Closure · Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Exceptions\ServiceNotRegistered · Phalcon\Html\Helper\Anchor · Phalcon\Html\Helper\Base · Phalcon\Html\Helper\Body · Phalcon\Html\Helper\Breadcrumbs · Phalcon\Html\Helper\Button · Phalcon\Html\Helper\Close · Phalcon\Html\Helper\Doctype · Phalcon\Html\Helper\Element · Phalcon\Html\Helper\Form · Phalcon\Html\Helper\FriendlyTitle · Phalcon\Html\Helper\Img · Phalcon\Html\Helper\Input\Checkbox · Phalcon\Html\Helper\Input\CheckboxGroup · Phalcon\Html\Helper\Input\Generic · Phalcon\Html\Helper\Input\Radio · Phalcon\Html\Helper\Input\RadioGroup · Phalcon\Html\Helper\Input\Select · Phalcon\Html\Helper\Input\Textarea · Phalcon\Html\Helper\Label · Phalcon\Html\Helper\Link · Phalcon\Html\Helper\Meta · Phalcon\Html\Helper\Ol · Phalcon\Html\Helper\Preload · Phalcon\Html\Helper\Script · Phalcon\Html\Helper\Style · Phalcon\Html\Helper\Tag · Phalcon\Html\Helper\Title · Phalcon\Html\Helper\Ul · Phalcon\Html\Helper\VoidTag · Phalcon\Http\ResponseInterface · Phalcon\Mvc\Url\UrlInterface

Method Summary

Properties

protected array $factories = []
protected array $instances = []

Methods

Public · 5

__call()

public function __call(
    string $name,
    array $arguments
);

Magic call to make the helper objects available as methods.

__construct()

public function __construct(
    EscaperInterface $escaper,
    array $services = [],
    ResponseInterface $response = null,
    UrlInterface $url = null
);

TagFactory constructor.

has()

public function has( string $name ): bool;

newInstance()

public function newInstance( string $name ): object;

Create or return a cached instance of the helper.

set()

public function set(
    string $name,
    Closure $definition
): void;

Register a helper via a zero-argument Closure. The Closure is invoked on the first matching newInstance() call and its return value is cached. Passing a new definition clears any cached instance so the next call to newInstance() rebuilds it.

Protected · 1

getDefaultServices()

protected function getDefaultServices(): array;

Default service recipes. Every entry is a Closure that returns a fully-constructed helper instance. Services are built lazily and cached.