lithium\template\helper\Form::label()
Generates an HTML <label></label>
object.
Parameters
-
string
$id
The DOM ID of the field that the label is for.
-
string
$title
The content inside the
<label></label>
object. -
array
$options
Besides HTML attributes, this parameter allows one additional flag:
'escape'
boolean: Defaults totrue
. Indicates whether the title of the label should be escaped. Iffalse
, it will be treated as raw HTML.
Returns
stringReturns a <label>
tag for the name and with HTML attributes.
Source
public function label($id, $title = null, array $options = []) {
$defaults = ['escape' => true];
if (is_array($title)) {
$options = current($title);
$title = key($title);
}
$title = $title ?: Inflector::humanize(str_replace('.', '_', $id));
list($name, $options, $template) = $this->_defaults(__FUNCTION__, $id, $options);
list($scope, $options) = $this->_options($defaults, $options);
if (strpos($id, '.')) {
$generator = $this->_config['attributes']['id'];
$id = $generator(__METHOD__, $id, $options);
}
return $this->_render(__METHOD__, $template, compact('id', 'title', 'options'), $scope);
}