Phalcon tag
NOTE
All classes are prefixed with Phalcon
Tag¶
Class Source on GitHub
Phalcon\Tag is designed to simplify building of HTML tags. It provides a set of helpers to generate HTML in a dynamic way. This component is a class that you can extend to add more helpers.
Phalcon\Tag
Uses Phalcon\Di\Di · Phalcon\Di\DiInterface · Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\Link\Link · Phalcon\Html\Link\Serializer\Header · Phalcon\Mvc\Url · Phalcon\Mvc\Url\UrlInterface · Phalcon\Support\Helper\Str\Friendly · Phalcon\Tag\Exception · Phalcon\Tag\Select · Stringable
Method Summary¶
public
void
appendTitle( mixed $title )
Appends a text to current document title
public
string
checkField( mixed $parameters )
Builds an HTML input[type="check"] tag
public
string
colorField( mixed $parameters )
Builds an HTML input[type="color"] tag
public
string
dateField( mixed $parameters )
Builds an HTML input[type="date"] tag
public
string
dateTimeField( mixed $parameters )
Builds an HTML input[type="datetime"] tag
public
string
dateTimeLocalField( mixed $parameters )
Builds an HTML input[type="datetime-local"] tag
public
void
displayTo(string $id,mixed $value)
Alias of Phalcon\Tag::setDefault()
public
string
emailField( mixed $parameters )
Builds an HTML input[type="email"] tag
public
string
endForm()
Builds an HTML close FORM tag
public
string
fileField( mixed $parameters )
Builds an HTML input[type="file"] tag
public
string
formLegacy( mixed $parameters )
Builds an HTML FORM tag
public
string
friendlyTitle(string $text,string $separator = "-",bool $lowercase = true,mixed $replace = null)
Converts texts into URL-friendly titles
public
DiInterface
getDI()
Internally gets the request dispatcher
public
string
getDocType()
Get the document type declaration of content
public
EscaperInterface|null
getEscaper( array $params )
Obtains the 'escaper' service if required
public
EscaperInterface
getEscaperService()
Returns an Escaper service from the default DI
public
string
getTitle(bool $prepend = true,bool $append = true)
Gets the current document title. The title will be automatically escaped.
public
string
getTitleSeparator()
Gets the current document title separator
public
UrlInterface
getUrlService()
Returns a URL service from the default DI
public
mixed
getValue(mixed $name,array $params = [])
Every helper calls this function to check whether a component has a
public
bool
hasValue( mixed $name )
Check if a helper has a default value set using Phalcon\Tag::setDefault()
public
string
hiddenField( mixed $parameters )
Builds a HTML input[type="hidden"] tag
public
string
image(mixed $parameters = null,bool $local = true)
Builds HTML IMG tags
public
string
imageInput( mixed $parameters )
Builds an HTML input[type="image"] tag
public
string
javascriptInclude(mixed $parameters = null,bool $local = true)
Builds a SCRIPT[type="javascript"] tag
public
string
linkTo(mixed $parameters,mixed $text = null,mixed $local = true)
Builds an HTML A tag using framework conventions
public
string
monthField( mixed $parameters )
Builds an HTML input[type="month"] tag
public
string
numericField( mixed $parameters )
Builds an HTML input[type="number"] tag
public
string
passwordField( mixed $parameters )
Builds a HTML input[type="password"] tag
public
string
preload( mixed $parameters )
Parses the preload element passed and sets the necessary link headers
public
void
prependTitle( mixed $title )
Prepends a text to current document title
public
string
radioField( mixed $parameters )
Builds an HTML input[type="radio"] tag
public
string
rangeField( mixed $parameters )
Builds an HTML input[type="range"] tag
public
string
renderAttributes(string $code,array $attributes)
Renders parameters keeping order in their HTML attributes
public
string
renderTitle(bool $prepend = true,bool $append = true)
Renders the title with title tags. The title is automatically escaped
public
void
resetInput()
Resets the request and internal values to avoid those fields will have
public
string
searchField( mixed $parameters )
Builds a HTML input[type="search"] tag
public
string
select(mixed $parameters,mixed $data = null)
Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options
public
string
selectStatic(mixed $parameters,mixed $data = null)
Builds an HTML SELECT tag using a PHP array for options
public
void
setAutoescape( bool $autoescape )
Set autoescape mode in generated HTML
public
void
setDI( DiInterface $container )
Sets the dependency injector container.
public
void
setDefault(string $id,mixed $value)
Assigns default values to generated tags by helpers
public
void
setDefaults(array $values,bool $merge = false)
Assigns default values to generated tags by helpers
public
void
setDocType( int $doctype )
Set the document type of content
public
void
setTitle( string $title )
Set the title of view content
public
void
setTitleSeparator( string $titleSeparator )
Set the title separator of view content
public
string
stylesheetLink(mixed $parameters = null,bool $local = true)
Builds a LINK[rel="stylesheet"] tag
public
string
submitButton( mixed $parameters )
Builds an HTML input[type="submit"] tag
public
string
tagHtml(string $tagName,mixed $parameters = null,bool $selfClose = false,bool $onlyStart = false,bool $useEol = false)
Builds a HTML tag
public
string
tagHtmlClose(string $tagName,bool $useEol = false)
Builds a HTML tag closing tag
public
string
telField( mixed $parameters )
Builds an HTML input[type="tel"] tag
public
string
textArea( mixed $parameters )
Builds an HTML TEXTAREA tag
public
string
textField( mixed $parameters )
Builds an HTML input[type="text"] tag
public
string
timeField( mixed $parameters )
Builds an HTML input[type="time"] tag
public
string
urlField( mixed $parameters )
Builds an HTML input[type="url"] tag
public
string
weekField( mixed $parameters )
Builds an HTML input[type="week"] tag
protected
string
getStaticUrl( mixed $uri )
Resolves a static (asset) URL through the url service.
protected
string
inputField(string $type,mixed $parameters,bool $asValue = false)
Builds generic INPUT tags
protected
string
inputFieldChecked(string $type,mixed $parameters)
Builds INPUT tags that implements the checked attribute
protected
string
toStringValue( mixed $value )
Reduces an arbitrary helper value to the string a tag attribute, id or
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
Properties¶
protected
bool
$autoEscape = true
protected
DiInterface|null
$container = null
protected
array
$displayValues = []
protected
array
$documentAppendTitle = []
protected
array
$documentPrependTitle = []
protected
string|null
$documentTitle = null
protected
string|null
$documentTitleSeparator = null
protected
int
$documentType = 11
protected
EscaperInterface|null
$escaperService = null
protected
UrlInterface|null
$urlService = null
Methods¶
appendTitle()¶
Appends a text to current document title
checkField()¶
Builds an HTML input[type="check"] tag
colorField()¶
Builds an HTML input[type="color"] tag
dateField()¶
Builds an HTML input[type="date"] tag
dateTimeField()¶
Builds an HTML input[type="datetime"] tag
dateTimeLocalField()¶
Builds an HTML input[type="datetime-local"] tag
displayTo()¶
Alias of Phalcon\Tag::setDefault()
emailField()¶
Builds an HTML input[type="email"] tag
endForm()¶
Builds an HTML close FORM tag
fileField()¶
Builds an HTML input[type="file"] tag
formLegacy()¶
Builds an HTML FORM tag
friendlyTitle()¶
public static function friendlyTitle(
string $text,
string $separator = "-",
bool $lowercase = true,
mixed $replace = null
): string;
Converts texts into URL-friendly titles
getDI()¶
Internally gets the request dispatcher
getDocType()¶
Get the document type declaration of content
getEscaper()¶
Obtains the 'escaper' service if required
getEscaperService()¶
Returns an Escaper service from the default DI
getTitle()¶
Gets the current document title. The title will be automatically escaped.
getTitleSeparator()¶
Gets the current document title separator
getUrlService()¶
Returns a URL service from the default DI
getValue()¶
Every helper calls this function to check whether a component has a predefined value using Phalcon\Tag::setDefault() or value from $_POST
hasValue()¶
Check if a helper has a default value set using Phalcon\Tag::setDefault() or value from $_POST
hiddenField()¶
Builds a HTML input[type="hidden"] tag
image()¶
Builds HTML IMG tags
imageInput()¶
Builds an HTML input[type="image"] tag
javascriptInclude()¶
Builds a SCRIPT[type="javascript"] tag
linkTo()¶
public static function linkTo(
mixed $parameters,
mixed $text = null,
mixed $local = true
): string;
Builds an HTML A tag using framework conventions
monthField()¶
Builds an HTML input[type="month"] tag
numericField()¶
Builds an HTML input[type="number"] tag
passwordField()¶
Builds a HTML input[type="password"] tag
preload()¶
Parses the preload element passed and sets the necessary link headers
prependTitle()¶
Prepends a text to current document title
radioField()¶
Builds an HTML input[type="radio"] tag
rangeField()¶
Builds an HTML input[type="range"] tag
renderAttributes()¶
Renders parameters keeping order in their HTML attributes
renderTitle()¶
Renders the title with title tags. The title is automatically escaped
resetInput()¶
Resets the request and internal values to avoid those fields will have any default value.
searchField()¶
Builds a HTML input[type="search"] tag
select()¶
Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options
selectStatic()¶
Builds an HTML SELECT tag using a PHP array for options
setAutoescape()¶
Set autoescape mode in generated HTML
setDI()¶
Sets the dependency injector container.
setDefault()¶
Assigns default values to generated tags by helpers
setDefaults()¶
Assigns default values to generated tags by helpers
setDocType()¶
Set the document type of content
setTitle()¶
Set the title of view content
setTitleSeparator()¶
Set the title separator of view content
stylesheetLink()¶
Builds a LINK[rel="stylesheet"] tag
submitButton()¶
Builds an HTML input[type="submit"] tag
tagHtml()¶
public static function tagHtml(
string $tagName,
mixed $parameters = null,
bool $selfClose = false,
bool $onlyStart = false,
bool $useEol = false
): string;
Builds a HTML tag
tagHtmlClose()¶
Builds a HTML tag closing tag
telField()¶
Builds an HTML input[type="tel"] tag
textArea()¶
Builds an HTML TEXTAREA tag
textField()¶
Builds an HTML input[type="text"] tag
timeField()¶
Builds an HTML input[type="time"] tag
urlField()¶
Builds an HTML input[type="url"] tag
weekField()¶
Builds an HTML input[type="week"] tag
getStaticUrl()¶
Resolves a static (asset) URL through the url service.
getStatic() lives on Phalcon\Mvc\Url but is absent from
Phalcon\Mvc\Url\UrlInterface, which is what getUrlService() is typed
to return. A service that does not carry it falls back to get()
rather than aborting the helper.
inputField()¶
final protected static function inputField(
string $type,
mixed $parameters,
bool $asValue = false
): string;
Builds generic INPUT tags
inputFieldChecked()¶
Builds INPUT tags that implements the checked attribute
toStringValue()¶
Reduces an arbitrary helper value to the string a tag attribute, id or
URI needs. Parameter bags are user supplied, so a value that cannot be
expressed as a string - an array, an object without __toString() -
reads back as an empty string rather than aborting the helper.
Tag\Exception¶
Class Source on GitHub
Phalcon\Tag\Exception
Exceptions thrown in Phalcon\Tag will use this class
\ExceptionPhalcon\Tag\Exception
Tag\Select¶
Abstract Source on GitHub
Phalcon\Tag\Select
Generates a SELECT HTML tag using a static array of values or a Phalcon\Mvc\Model resultset
Phalcon\Tag\Select
Uses Phalcon\Html\Escaper\EscaperInterface · Phalcon\Mvc\Model\ResultsetInterface · Phalcon\Tag · Stringable
Method Summary¶
public
string
selectField(mixed $parameters,mixed $data = null)
Generates a SELECT tag
protected
string
echoOption(string $value,bool $selected = false)
protected
string
toStringValue( mixed $value )
Reduces an arbitrary option value to the string the markup needs.
Methods¶
selectField()¶
Generates a SELECT tag
echoOption()¶
toStringValue()¶
Reduces an arbitrary option value to the string the markup needs. Option data is user supplied, so anything that cannot be expressed as a string reads back as an empty string rather than aborting the tag.