kartik-v / yii2-widgets

Collection of useful widgets for Yii Framework 2.0
http://demos.krajee.com/widgets
Other
558 stars 177 forks source link

[FileInput] isBs4 always false #365

Closed misyuari closed 6 years ago

misyuari commented 6 years ago

public function isBs4() { if (!isset($this->_isBs4)) { $this->initBsVersion(); } var_dump($this);die; return $this->_isBs4; } get return object(kartik\file\SortableAsset)#423 (12) { ["bsVersion"]=> NULL ["bsPluginEnabled"]=> bool(false) ["depends"]=> array(1) { [0]=> string(16) "yii\web\YiiAsset" } ["_isBs4":"kartik\base\AssetBundle":private]=> bool(false) ["js"]=> array(1) { [0]=> string(22) "js/plugins/sortable.js" } ["css"]=> string(9) "K3/@$$3T$" ["sourcePath"]=> string(36) "@vendor/kartik-v/bootstrap-fileinput" ["basePath"]=> NULL ["baseUrl"]=> NULL ["jsOptions"]=> array(0) { } ["cssOptions"]=> array(0) { } ["publishOptions"]=> array(0) { } }

here my view

        <?php echo $form->field($model, 'photo_path')->widget(\kartik\file\FileInput::className(),
            [
                'options' => ['accept' => 'image/*'],
                'bsVersion' => '4.x',
                'pluginOptions' => [
                    'showCaption' => true,
                    'showRemove' => false,
                    'showUpload' => false,
                    'initialPreview' => $model->photo_path ? HTML::img(Yii::$app->getUrlManager()->getBaseUrl().'/'.$model->photo_path, ['width' => 100]) : '',
                    'overwriteInitial' => true,
                ]
            ]
        );?>
kartik-v commented 6 years ago

Check the Fileinput widget docs on how to configure widget for Bootstrap 4 (and the required pre-requisites).