Answer the question
In order to leave comments, you need to log in
How to make kartik fileInput required?
I use the download widget:
https://github.com/kartik-v/yii2-widget-fileinput
My brain is already boiling. I can't figure out how to make it a required field. I use activeForm with ajax validation.
Here is the view:
$form->field($forma,'userimg')->widget(FileInput::classname(),[
'options' => ['accept' => 'image/*'],
'pluginOptions' => [
'allowedFileExtensions'=>['jpg', 'gif', 'png', 'bmp'],
'previewFileType' => 'image',
'showRemove' => false,
'showUpload' => false,
'browseClass' => 'btn btn-primary btn-block',
'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ',
'browseLabel' => Yii::t('knopki', 'upload'),
'overwriteInitial'=>false,
]])
['userimg', 'image', 'extensions' => 'png,jpg,jpeg', 'skipOnEmpty' => false, 'maxSize'=>5000000, 'minSize'=>100000, 'uploadRequired'=>Yii::t('order', 'noImage')],
Answer the question
In order to leave comments, you need to log in
Most likely an error in the method of loading pictures. Can you provide a more detailed example?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question