Fr3nch13/CakePHP Utilities

HtmlHelper extends Helper
in package
uses StringTemplateTrait

Html Helper class for easy use of HTML widgets.

HtmlHelper encloses all methods needed while working with HTML pages.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html

Table of Contents

Properties

$Url  : UrlHelper
$_config  : array<string, mixed>
Runtime config
$_configInitialized  : bool
Whether the config property has already been configured with defaults
$_defaultConfig  : array<string, mixed>
Default config for this class
$_helperMap  : array<string, array<string|int, mixed>>
A helper lookup table used to lazy load helper objects.
$_includedAssets  : array<string, array<string|int, mixed>>
Names of script & css files that have been included once
$_scriptBlockOptions  : array<string, mixed>
Options for the currently opened script block buffer if any.
$_templater  : StringTemplate|null
StringTemplate instance.
$_View  : View
The View instance this helper is attached to
$helpers  : array<string|int, mixed>
List of helpers used by this helper

Methods

__call()  : mixed|void
Provide non fatal errors on missing method calls.
__construct()  : mixed
Default Constructor
__debugInfo()  : array<string, mixed>
Returns an array that can be used to describe the internal state of this object.
__get()  : Helper|null|void
Lazy loads helpers.
addClass()  : array<string, mixed>
Adds the given class to the element options
charset()  : string
Returns a charset META-tag.
configShallow()  : $this
Merge provided config with existing config. Unlike `config()` which does a recursive merge for nested keys, this method does a simple merge.
css()  : string|null
Creates a link element for CSS stylesheets.
div()  : string
Returns a formatted DIV tag for HTML FORMs.
formatTemplate()  : string
Formats a template string with $data
getConfig()  : mixed
Returns the config.
getConfigOrFail()  : mixed
Returns the config for this specific key.
getTemplates()  : array<string|int, mixed>|string
Gets templates to use or a specific template.
getView()  : View
Get the view instance this helper is bound to.
image()  : string
Creates a formatted IMG element.
implementedEvents()  : array<string, mixed>
Event listeners.
initialize()  : void
Constructor hook method.
link()  : string
Creates an HTML link.
linkFromPath()  : string
Creates an HTML link from route path string.
media()  : string
Returns an audio/video element
meta()  : string|null
Creates a link to an external resource and handles basic meta tags
nestedList()  : string
Build a nested list (UL/OL) out of an associative array.
para()  : string
Returns a formatted P tag.
script()  : string|null
Returns one or many `<script>` tags depending on the number of scripts given.
scriptBlock()  : string|null
Wrap $script in a script tag.
scriptEnd()  : string|null
End a Buffered section of JavaScript capturing.
scriptStart()  : void
Begin a script block that captures output until HtmlHelper::scriptEnd() is called. This capturing block will capture all output between the methods and create a scriptBlock from it.
setConfig()  : $this
Sets the config.
setTemplates()  : $this
Sets templates to use.
style()  : string
Builds CSS style data from an array of CSS properties
tableCell()  : string
Renders a single table cell (A TD with attributes).
tableCells()  : string
Returns a formatted string of table rows (TR's with TD's in them).
tableHeaders()  : string
Returns a row of formatted and named TABLE headers.
tableRow()  : string
Renders a single table row (A TR with attributes).
tag()  : string
Returns a formatted block tag, i.e DIV, SPAN, P.
templater()  : StringTemplate
Returns the templater instance.
_configDelete()  : void
Deletes a single config key.
_configRead()  : mixed
Reads a config key.
_configWrite()  : void
Writes a config key.
_confirm()  : string
Returns a string to be used as onclick handler for confirm dialogs.
_nestedListItem()  : string
Internal function to build a nested list (UL/OL) out of an associative array.
_renderCells()  : array<string|int, string>
Renders cells for a row of a table.

Properties

$_configInitialized

Whether the config property has already been configured with defaults

protected bool $_configInitialized = false

$_defaultConfig

Default config for this class

protected array<string, mixed> $_defaultConfig = ['templates' => ['meta' => '<meta{{attrs}}/>', 'metalink' => '<link href="{{url}}"{{attrs}}/>', 'link' => '<a href="{{url}}"{{attrs}}>{{content}}</a>', 'mailto' => '<a href="mailto:{{url}}"{{attrs}}>{{content}}</a>', 'image' => '<img src="{{url}}"{{attrs}}/>', 'tableheader' => '<th{{attrs}}>{{content}}</th>', 'tableheaderrow' => '<tr{{attrs}}>{{content}}</tr>', 'tablecell' => '<td{{attrs}}>{{content}}</td>', 'tablerow' => '<tr{{attrs}}>{{content}}</tr>', 'block' => '<div{{attrs}}>{{content}}</div>', 'blockstart' => '<div{{attrs}}>', 'blockend' => '</div>', 'tag' => '<{{tag}}{{attrs}}>{{content}}</{{tag}}>', 'tagstart' => '<{{tag}}{{attrs}}>', 'tagend' => '</{{tag}}>', 'tagselfclosing' => '<{{tag}}{{attrs}}/>', 'para' => '<p{{attrs}}>{{content}}</p>', 'parastart' => '<p{{attrs}}>', 'css' => '<link rel="{{rel}}" href="{{url}}"{{attrs}}/>', 'style' => '<style{{attrs}}>{{content}}</style>', 'charset' => '<meta charset="{{charset}}"/>', 'ul' => '<ul{{attrs}}>{{content}}</ul>', 'ol' => '<ol{{attrs}}>{{content}}</ol>', 'li' => '<li{{attrs}}>{{content}}</li>', 'javascriptblock' => '<script{{attrs}}>{{content}}</script>', 'javascriptstart' => '<script>', 'javascriptlink' => '<script src="{{url}}"{{attrs}}></script>', 'javascriptend' => '</script>', 'confirmJs' => '{{confirm}}']]

$_helperMap

A helper lookup table used to lazy load helper objects.

protected array<string, array<string|int, mixed>> $_helperMap = []

$_includedAssets

Names of script & css files that have been included once

protected array<string, array<string|int, mixed>> $_includedAssets = []

$_scriptBlockOptions

Options for the currently opened script block buffer if any.

protected array<string, mixed> $_scriptBlockOptions = []

$_View

The View instance this helper is attached to

protected View $_View

$helpers

List of helpers used by this helper

protected array<string|int, mixed> $helpers = ['Url']

Methods

__call()

Provide non fatal errors on missing method calls.

public __call(string $method, array<string|int, mixed> $params) : mixed|void
Parameters
$method : string

Method to invoke

$params : array<string|int, mixed>

Array of params for the method.

Return values
mixed|void

__construct()

Default Constructor

public __construct(View $view[, array<string, mixed> $config = [] ]) : mixed
Parameters
$view : View

The View this helper is being attached to.

$config : array<string, mixed> = []

Configuration settings for the helper.

__debugInfo()

Returns an array that can be used to describe the internal state of this object.

public __debugInfo() : array<string, mixed>
Return values
array<string, mixed>

__get()

Lazy loads helpers.

public __get(string $name) : Helper|null|void
Parameters
$name : string

Name of the property being accessed.

Return values
Helper|null|void

Helper instance if helper with provided name exists

addClass()

Adds the given class to the element options

public addClass(array<string, mixed> $options, string $class[, string $key = 'class' ]) : array<string, mixed>
Parameters
$options : array<string, mixed>

Array options/attributes to add a class to

$class : string

The class name being added.

$key : string = 'class'

the key to use for class. Defaults to 'class'.

Return values
array<string, mixed>

Array of options with $key set.

configShallow()

Merge provided config with existing config. Unlike `config()` which does a recursive merge for nested keys, this method does a simple merge.

public configShallow(array<string, mixed>|string $key[, mixed|null $value = null ]) : $this

Setting a specific value:

$this->configShallow('key', $value);

Setting a nested value:

$this->configShallow('some.nested.key', $value);

Updating multiple config settings at the same time:

$this->configShallow(['one' => 'value', 'another' => 'value']);
Parameters
$key : array<string, mixed>|string

The key to set, or a complete array of configs.

$value : mixed|null = null

The value to set.

Return values
$this

css()

Creates a link element for CSS stylesheets.

public css(array<string|int, string>|string $path[, array<string, mixed> $options = [] ]) : string|null

Usage

Include one CSS file:

echo $this->Html->css('styles.css');

Include multiple CSS files:

echo $this->Html->css(['one.css', 'two.css']);

Add the stylesheet to view block "css":

$this->Html->css('styles.css', ['block' => true]);

Add the stylesheet to a custom block:

$this->Html->css('styles.css', ['block' => 'layoutCss']);

Options

  • block Set to true to append output to view block "css" or provide custom block name.
  • once Whether the css file should be checked for uniqueness. If true css files will only be included once, use false to allow the same css to be included more than once per request.
  • plugin False value will prevent parsing path as a plugin
  • rel Defaults to 'stylesheet'. If equal to 'import' the stylesheet will be imported.
  • fullBase If true the URL will get a full address for the css file.

All other options will be treated as HTML attributes. If the request contains a cspStyleNonce attribute, that value will be applied as the nonce attribute on the generated HTML.

Parameters
$path : array<string|int, string>|string

The name of a CSS style sheet or an array containing names of CSS stylesheets. If $path is prefixed with '/', the path will be relative to the webroot of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css.

$options : array<string, mixed> = []

Array of options and HTML arguments.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#linking-to-css-files
Return values
string|null

CSS <link /> or <style /> tag, depending on the type of link.

div()

Returns a formatted DIV tag for HTML FORMs.

public div([string|null $class = null ][, string|null $text = null ][, array<string, mixed> $options = [] ]) : string

Options

  • escape Whether the contents should be html_entity escaped.
Parameters
$class : string|null = null

CSS class name of the div element.

$text : string|null = null

String content that will appear inside the div element. If null, only a start tag will be printed

$options : array<string, mixed> = []

Additional HTML attributes of the DIV tag

Return values
string

The formatted DIV element

formatTemplate()

Formats a template string with $data

public formatTemplate(string $name, array<string, mixed> $data) : string
Parameters
$name : string

The template name.

$data : array<string, mixed>

The data to insert.

Return values
string

getConfig()

Returns the config.

public getConfig([string|null $key = null ][, mixed $default = null ]) : mixed

Usage

Reading the whole config:

$this->getConfig();

Reading a specific value:

$this->getConfig('key');

Reading a nested value:

$this->getConfig('some.nested.key');

Reading with default value:

$this->getConfig('some-key', 'default-value');
Parameters
$key : string|null = null

The key to get or null for the whole config.

$default : mixed = null

The return value when the key does not exist.

Return values
mixed

Configuration data at the named key or null if the key does not exist.

getConfigOrFail()

Returns the config for this specific key.

public getConfigOrFail(string $key) : mixed

The config value for this key must exist, it can never be null.

Parameters
$key : string

The key to get.

Tags
throws
InvalidArgumentException
Return values
mixed

Configuration data at the named key

getTemplates()

Gets templates to use or a specific template.

public getTemplates([string|null $template = null ]) : array<string|int, mixed>|string
Parameters
$template : string|null = null

String for reading a specific template, null for all.

Return values
array<string|int, mixed>|string

getView()

Get the view instance this helper is bound to.

public getView() : View
Return values
View

The bound view instance.

image()

Creates a formatted IMG element.

public image(array<string|int, mixed>|string $path[, array<string, mixed> $options = [] ]) : string

This method will set an empty alt attribute if one is not supplied.

Usage:

Create a regular image:

echo $this->Html->image('cake_icon.png', ['alt' => 'CakePHP']);

Create an image link:

echo $this->Html->image('cake_icon.png', ['alt' => 'CakePHP', 'url' => 'https://cakephp.org']);

Options:

  • url If provided an image link will be generated and the link will point at $options['url'].
  • fullBase If true the src attribute will get a full address for the image file.
  • plugin False value will prevent parsing path as a plugin
Parameters
$path : array<string|int, mixed>|string

Path to the image file, relative to the webroot/img/ directory.

$options : array<string, mixed> = []

Array of HTML attributes. See above for special options.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#linking-to-images
Return values
string

completed img tag

implementedEvents()

Event listeners.

public implementedEvents() : array<string, mixed>
Return values
array<string, mixed>

initialize()

Constructor hook method.

public initialize(array<string, mixed> $config) : void

Implement this method to avoid having to overwrite the constructor and call parent.

Parameters
$config : array<string, mixed>

The configuration settings provided to this helper.

Creates an HTML link.

public link(array<string|int, mixed>|string $title[, array<string|int, mixed>|string|null $url = null ][, array<string, mixed> $options = [] ]) : string

If $url starts with "http://" this is treated as an external link. Else, it is treated as a path to controller/action and parsed with the UrlHelper::build() method.

If the $url is empty, $title is used instead.

Options

  • escape Set to false to disable escaping of title and attributes.
  • escapeTitle Set to false to disable escaping of title. Takes precedence over value of escape)
  • confirm JavaScript confirmation message.
Parameters
$title : array<string|int, mixed>|string

The content to be wrapped by <a> tags. Can be an array if $url is null. If $url is null, $title will be used as both the URL and title.

$url : array<string|int, mixed>|string|null = null

Cake-relative URL or array of URL parameters, or external URL (starts with http://)

$options : array<string, mixed> = []

Array of options and HTML attributes.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-links
Return values
string

An <a /> element.

linkFromPath()

Creates an HTML link from route path string.

public linkFromPath(string $title, string $path[, array<string|int, mixed> $params = [] ][, array<string, mixed> $options = [] ]) : string

Options

  • escape Set to false to disable escaping of title and attributes.
  • escapeTitle Set to false to disable escaping of title. Takes precedence over value of escape)
  • confirm JavaScript confirmation message.
Parameters
$title : string

The content to be wrapped by <a> tags.

$path : string

Cake-relative route path.

$params : array<string|int, mixed> = []

An array specifying any additional parameters. Can be also any special parameters supported by Router::url().

$options : array<string, mixed> = []

Array of options and HTML attributes.

Tags
see
Router::pathUrl()
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-links
Return values
string

An <a /> element.

media()

Returns an audio/video element

public media(array<string|int, mixed>|string $path[, array<string, mixed> $options = [] ]) : string

Usage

Using an audio file:

echo $this->Html->media('audio.mp3', ['fullBase' => true]);

Outputs:

<video src="http://www.somehost.com/files/audio.mp3">Fallback text</video>

Using a video file:

echo $this->Html->media('video.mp4', ['text' => 'Fallback text']);

Outputs:

<video src="/files/video.mp4">Fallback text</video>

Using multiple video files:

echo $this->Html->media(
     ['video.mp4', ['src' => 'video.ogv', 'type' => "video/ogg; codecs='theora, vorbis'"]],
     ['tag' => 'video', 'autoplay']
);

Outputs:

<video autoplay="autoplay">
     <source src="/files/video.mp4" type="video/mp4"/>
     <source src="/files/video.ogv" type="video/ogv; codecs='theora, vorbis'"/>
</video>

Options

  • tag Type of media element to generate, either "audio" or "video". If tag is not provided it's guessed based on file's mime type.
  • text Text to include inside the audio/video tag
  • pathPrefix Path prefix to use for relative URLs, defaults to 'files/'
  • fullBase If provided the src attribute will get a full address including domain name
Parameters
$path : array<string|int, mixed>|string

Path to the video file, relative to the webroot/{$options['pathPrefix']} directory. Or an array where each item itself can be a path string or an associate array containing keys src and type

$options : array<string, mixed> = []

Array of HTML attributes, and special options above.

Return values
string

Generated media element

meta()

Creates a link to an external resource and handles basic meta tags

public meta(array<string, mixed>|string $type[, array<string|int, mixed>|string|null $content = null ][, array<string, mixed> $options = [] ]) : string|null

Create a meta tag that is output inline:

$this->Html->meta('icon', 'favicon.ico');

Append the meta tag to custom view block "meta":

$this->Html->meta('description', 'A great page', ['block' => true]);

Append the meta tag to custom view block:

$this->Html->meta('description', 'A great page', ['block' => 'metaTags']);

Create a custom meta tag:

$this->Html->meta(['property' => 'og:site_name', 'content' => 'CakePHP']);

Options

  • block - Set to true to append output to view block "meta" or provide custom block name.
Parameters
$type : array<string, mixed>|string

The title of the external resource, Or an array of attributes for a custom meta tag.

$content : array<string|int, mixed>|string|null = null

The address of the external resource or string for content attribute

$options : array<string, mixed> = []

Other attributes for the generated tag. If the type attribute is html, rss, atom, or icon, the mime-type is returned.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-meta-tags
Return values
string|null

A completed <link /> element, or null if the element was sent to a block.

nestedList()

Build a nested list (UL/OL) out of an associative array.

public nestedList(array<string|int, mixed> $list[, array<string, mixed> $options = [] ][, array<string, mixed> $itemOptions = [] ]) : string

Options for $options:

  • tag - Type of list tag to use (ol/ul)

Options for $itemOptions:

  • even - Class to use for even rows.
  • odd - Class to use for odd rows.
Parameters
$list : array<string|int, mixed>

Set of elements to list

$options : array<string, mixed> = []

Options and additional HTML attributes of the list (ol/ul) tag.

$itemOptions : array<string, mixed> = []

Options and additional HTML attributes of the list item (LI) tag.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-nested-lists
Return values
string

The nested list

para()

Returns a formatted P tag.

public para(string|null $class, string|null $text[, array<string, mixed> $options = [] ]) : string

Options

  • escape Whether the contents should be html_entity escaped.
Parameters
$class : string|null

CSS class name of the p element.

$text : string|null

String content that will appear inside the p element.

$options : array<string, mixed> = []

Additional HTML attributes of the P tag

Return values
string

The formatted P element

script()

Returns one or many `<script>` tags depending on the number of scripts given.

public script(array<string|int, string>|string $url[, array<string, mixed> $options = [] ]) : string|null

If the filename is prefixed with "/", the path will be relative to the base path of your application. Otherwise, the path will be relative to your JavaScript path, usually webroot/js.

Usage

Include one script file:

echo $this->Html->script('styles.js');

Include multiple script files:

echo $this->Html->script(['one.js', 'two.js']);

Add the script file to a custom block:

$this->Html->script('styles.js', ['block' => 'bodyScript']);

Options

  • block Set to true to append output to view block "script" or provide custom block name.
  • once Whether the script should be checked for uniqueness. If true scripts will only be included once, use false to allow the same script to be included more than once per request.
  • plugin False value will prevent parsing path as a plugin
  • fullBase If true the url will get a full address for the script file.

All other options will be added as attributes to the generated script tag. If the current request has a cspScriptNonce attribute, that value will be inserted as a nonce attribute on the script tag.

Parameters
$url : array<string|int, string>|string

String or array of javascript files to include

$options : array<string, mixed> = []

Array of options, and html attributes see above.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#linking-to-javascript-files
Return values
string|null

String of <script /> tags or null if block is specified in options or if $once is true and the file has been included before.

scriptBlock()

Wrap $script in a script tag.

public scriptBlock(string $script[, array<string, mixed> $options = [] ]) : string|null

Options

  • block Set to true to append output to view block "script" or provide custom block name.
Parameters
$script : string

The script to wrap

$options : array<string, mixed> = []

The options to use. Options not listed above will be treated as HTML attributes.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-inline-javascript-blocks
Return values
string|null

String or null depending on the value of $options['block']

scriptStart()

Begin a script block that captures output until HtmlHelper::scriptEnd() is called. This capturing block will capture all output between the methods and create a scriptBlock from it.

public scriptStart([array<string, mixed> $options = [] ]) : void

Options

  • block Set to true to append output to view block "script" or provide custom block name.
Parameters
$options : array<string, mixed> = []

Options for the code block.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-inline-javascript-blocks

setConfig()

Sets the config.

public setConfig(array<string, mixed>|string $key[, mixed|null $value = null ][, bool $merge = true ]) : $this

Usage

Setting a specific value:

$this->setConfig('key', $value);

Setting a nested value:

$this->setConfig('some.nested.key', $value);

Updating multiple config settings at the same time:

$this->setConfig(['one' => 'value', 'another' => 'value']);
Parameters
$key : array<string, mixed>|string

The key to set, or a complete array of configs.

$value : mixed|null = null

The value to set.

$merge : bool = true

Whether to recursively merge or overwrite existing config, defaults to true.

Tags
throws
CakeException

When trying to set a key that is invalid.

Return values
$this

setTemplates()

Sets templates to use.

public setTemplates(array<string|int, string> $templates) : $this
Parameters
$templates : array<string|int, string>

Templates to be added.

Return values
$this

style()

Builds CSS style data from an array of CSS properties

public style(array<string, string> $data[, bool $oneLine = true ]) : string

Usage:

echo $this->Html->style(['margin' => '10px', 'padding' => '10px'], true);

// creates
'margin:10px;padding:10px;'
Parameters
$data : array<string, string>

Style data array, keys will be used as property names, values as property values.

$oneLine : bool = true

Whether the style block should be displayed on one line.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-css-programatically
Return values
string

CSS styling data

tableCell()

Renders a single table cell (A TD with attributes).

public tableCell(string $content[, array<string, mixed> $options = [] ]) : string
Parameters
$content : string

The content of the cell.

$options : array<string, mixed> = []

HTML attributes.

Return values
string

tableCells()

Returns a formatted string of table rows (TR's with TD's in them).

public tableCells(array<string|int, mixed>|string $data[, array<string, mixed>|bool|null $oddTrOptions = null ][, array<string, mixed>|bool|null $evenTrOptions = null ][, bool $useCount = false ][, bool $continueOddEven = true ]) : string
Parameters
$data : array<string|int, mixed>|string

Array of table data

$oddTrOptions : array<string, mixed>|bool|null = null

HTML options for odd TR elements if true useCount is used

$evenTrOptions : array<string, mixed>|bool|null = null

HTML options for even TR elements

$useCount : bool = false

adds class "column-$i"

$continueOddEven : bool = true

If false, will use a non-static $count variable, so that the odd/even count is reset to zero just for that call.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-table-cells
Return values
string

Formatted HTML

tableHeaders()

Returns a row of formatted and named TABLE headers.

public tableHeaders(array<string|int, mixed> $names[, array<string, mixed>|null $trOptions = null ][, array<string, mixed>|null $thOptions = null ]) : string
Parameters
$names : array<string|int, mixed>

Array of tablenames. Each tablename can be string, or array with name and an array with a set of attributes to its specific tag

$trOptions : array<string, mixed>|null = null

HTML options for TR elements.

$thOptions : array<string, mixed>|null = null

HTML options for TH elements.

Tags
link
https://book.cakephp.org/4/en/views/helpers/html.html#creating-table-headings
Return values
string

Completed table headers

tableRow()

Renders a single table row (A TR with attributes).

public tableRow(string $content[, array<string, mixed> $options = [] ]) : string
Parameters
$content : string

The content of the row.

$options : array<string, mixed> = []

HTML attributes.

Return values
string

tag()

Returns a formatted block tag, i.e DIV, SPAN, P.

public tag(string $name[, string|null $text = null ][, array<string, mixed> $options = [] ]) : string

Options

  • escape Whether the contents should be html_entity escaped.
Parameters
$name : string

Tag name.

$text : string|null = null

String content that will appear inside the HTML element. If null, only a start tag will be printed

$options : array<string, mixed> = []

Additional HTML attributes of the HTML tag, see above.

Return values
string

The formatted tag element

_configDelete()

Deletes a single config key.

protected _configDelete(string $key) : void
Parameters
$key : string

Key to delete.

Tags
throws
CakeException

if attempting to clobber existing config

_configRead()

Reads a config key.

protected _configRead(string|null $key) : mixed
Parameters
$key : string|null

Key to read.

_configWrite()

Writes a config key.

protected _configWrite(array<string, mixed>|string $key, mixed $value[, string|bool $merge = false ]) : void
Parameters
$key : array<string, mixed>|string

Key to write to.

$value : mixed

Value to write.

$merge : string|bool = false

True to merge recursively, 'shallow' for simple merge, false to overwrite, defaults to false.

Tags
throws
CakeException

if attempting to clobber existing config

_confirm()

Returns a string to be used as onclick handler for confirm dialogs.

protected _confirm(string $okCode, string $cancelCode) : string
Parameters
$okCode : string

Code to be executed after user chose 'OK'

$cancelCode : string

Code to be executed after user chose 'Cancel'

Return values
string

"onclick" JS code

_nestedListItem()

Internal function to build a nested list (UL/OL) out of an associative array.

protected _nestedListItem(array<string|int, mixed> $items, array<string, mixed> $options, array<string, mixed> $itemOptions) : string
Parameters
$items : array<string|int, mixed>

Set of elements to list.

$options : array<string, mixed>

Additional HTML attributes of the list (ol/ul) tag.

$itemOptions : array<string, mixed>

Options and additional HTML attributes of the list item (LI) tag.

Tags
see
HtmlHelper::nestedList()
Return values
string

The nested list element

_renderCells()

Renders cells for a row of a table.

protected _renderCells(array<string|int, mixed> $line[, bool $useCount = false ]) : array<string|int, string>

This is a helper method for tableCells(). Overload this method as you need to change the behavior of the cell rendering.

Parameters
$line : array<string|int, mixed>

Line data to render.

$useCount : bool = false

Renders the count into the row. Default is false.

Return values
array<string|int, string>

        
On this page

Search results