如何更改kartik fileinput中的错误消息文本

时间:2018-04-15 17:19:26

标签: yii2 kartik-v

我正在使用kartik yii2 widget fileinput。我将'maxFileSize'设置为1024.当上传的文件超出允许的最大大小时,会显示错误消息,我想更改此错误文本并以格鲁吉亚语显示。我怎样才能做到这一点? 这是我的代码:

clc;
close all;
a = im2double(imread('343a.tif')); 
lap = [-1 -1 -1; -1 8 -1; -1 -1 -1]; 
resp = imfilter(a, lap, 'conv'); 


minR = min(resp(:));
maxR = max(resp(:));
resp = (resp - minR) / (maxR - minR);


sharpened = a + resp;

minA = min(sharpened(:));
maxA = max(sharpened(:));
sharpened = (sharpened - minA) / (maxA - minA);

sharpened = imadjust(sharpened, [60/255 200/255], [0 1]);

figure; 
subplot(1,3,1);imshow(a); title('Original image');
subplot(1,3,2);imshow(resp); title('Laplacian filtered image');
subplot(1,3,3);imshow(sharpened); title('Sharpened image');

我需要更改此错误消息:

enter image description here

2 个答案:

答案 0 :(得分:2)

您只需将此行添加到“pluginOptions”并自定义:

<?= $form->field($model, 'photo_name')->widget(FileInput::classname(), [
                'options'=>[
                    'id'=>'upload-img',
                    'multiple'=>false,
                    'accept'=>'image/*',
                ],
                'pluginOptions'=>[
                    .
                    .
                    .
                    'msgSizeTooLarge' => 'File "{name}" (<b>{size} KB</b>) exceeds maximum allowed upload size of <b>{maxSize} KB</b>.',
                ],
]); ?>

答案 1 :(得分:0)

您需要在模型验证规则中使用tooBig选项,您可以在其中指定规则应如下所示文件的maxSize

[[ 'photo_name'] , 'file' , 'extensions' => 'pdf, jpg' , 'maxSize' => 1024000 , 'tooBig' => 'Limit is 1024KB' ] ,

要以georgian或英语以外的其他方式显示,您应该查看Message Translation