Creates a form input. If no type is specified, a "text" type input will be returned.
echo Form::input('username', $username);
string Core_Form::input( string $name [, string $value = null , array $attributes = null ] )
参数列表
参数 类型 描述 默认值 $name
string
Input name $value
string
Input value null $attributes
array
Html attributes null
string
public static function input($name, $value = null, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input value
$attributes['value'] = $value;
if (!isset($attributes['type']))
{
// Default type is text
$attributes['type'] = 'text';
}
if ($attributes['type'] == 'text' && !isset($attributes['min']) && (!$attributes['value'] || preg_match('#^[0-9.]+$#', $attributes['value'])) && (int)$attributes['value']>=0)
{
$attributes['min'] = '0';
}
return '<input' . HTML::attributes($attributes) . ' />';
}