Yii2:如何更改kartik的fileinput小部件标题名称和浏览按钮大小?

时间:2018-03-14 08:12:04

标签: php yii yii2 kartik-v

我正在使用kartik的fileInput小部件。我需要做的是更改浏览图标的大小并更改标题名称(因为现在它是"选择文件")..我真的很挣扎,我找不到任何有关问题的信息。

这是我的小部件:

echo FileInput::widget([
    'model' => $model,
    'attribute' => 'user',
        'pluginOptions' => [
        'showPreview' => false,
        'showRemove' => false,
        'uploadLabel' => '',
        'uploadIcon' => '<i class="glyphicon glyphicon-ok"></i>',
        'browseLabel' => '',
        ]
]);

2 个答案:

答案 0 :(得分:1)

您可以使用browseClassbrowseIcon,如下所示

'browseClass' => 'btn btn-success btn-block' ,
'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ' ,

您可以调整css类btn btn-success属性以满足您的需求

答案 1 :(得分:0)

可以选择更改按钮标题browseLabel

echo '<label class="control-label">Project Images </label>';
echo FileInput::widget([
    'model' => $imagemodel,
    'attribute' => 'upload_image[]',
    'pluginOptions' => [
        'initialPreviewConfig' => $imagesListId,
        'overwriteInitial'=>false,
        'previewFileType' => 'image',
        'initialPreview' => $imagesListId1 ,
        'showRemove' => true,
       // 'deleteUrl'=>!empty($imagesID)? $imagesID:'',
        'browseIcon' => '<i class="glyphicon glyphicon-plus-sign"></i> ',
        'browseLabel' => 'Upload Image',
        'allowedFileExtensions' => ['jpg', 'png','jpeg','tiff','JPEG'],
        'previewFileType' => ['jpg', 'png','jpeg','tiff','JPEG'],
        'msgUploadBegin' => Yii::t('app', 'Please wait, system is uploading the files'),
        'msgFilesTooMany' => 'Maximum 5 Images are allowed to be uploaded.',
        "uploadAsync" => true,
        "browseOnZoneClick" => true,
        'maxFileSize' => 1024,
        'showPreview' => true,
        'showCaption' => true,
        'showRemove' => true,
        'showUpload' => false,
        
    ],
    'options' => ['multiple' => true]

]);

这是它的样子:
This is what it look likes