Creates a form label. Label text is not automatically translated.
echo Form::label('username', 'Username');
string Core_Form::label( string $input [, string $text = null , array $attributes = null ] )
参数列表
参数 类型 描述 默认值 $input
string
Target input $text
string
Label text null $attributes
array
Html attributes null
string
public static function label($input, $text = null, array $attributes = null)
{
if ($text === null)
{
// Use the input name as the text
$text = ucwords(preg_replace('/\W+/', ' ', $input));
}
// Set the label target
$attributes['for'] = $input;
return '<label' . HTML::attributes($attributes) . '>' . $text . '</label>';
}