public static activeFileInput ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated input tag |
public static function activeFileInput($model, $attribute, $options = [])
{
// add a hidden field so that if a model only has a file field, we can
// still use isset($_POST[$modelClass]) to detect if the input is submitted
$hiddenOptions = ['id' => null, 'value' => ''];
if (isset($options['name'])) {
$hiddenOptions['name'] = $options['name'];
}
return static::activeHiddenInput($model, $attribute, $hiddenOptions) . static::activeInput('file', $model, $attribute, $options);
}