kartik-v / yii2-detail-view

Various enhancements to the Yii 2 Detail View with ability to edit data and manage styles using BS3.
http://demos.krajee.com/detail-view
Other
70 stars 56 forks source link

Error: Calling unknown method: kartik\detail\DetailView::initBsVersion() #187

Closed strtob closed 2 years ago

strtob commented 2 years ago

Prerequisites

Steps to reproduce the issue

  1. Install current dev-master version
  2. use detailview

Expected behavior and actual behavior

When I follow those steps, I see...

I was expecting...

Environment

Browsers

Operating System

Libraries

Isolating the problem

I get the following error:

<pre>Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: kartik\detail\DetailView::initBsVersion()' 

in /opt/work/assetor/vendor/yiisoft/yii2/base/Component.php:300

Stack trace:
#0 /opt/work/assetor/vendor/kartik-v/yii2-detail-view/src/DetailView.php(816): yii\base\Component-&gt;__call()
#1 /opt/work/assetor/vendor/kartik-v/yii2-detail-view/src/DetailView.php(794): kartik\detail\DetailView-&gt;initWidget()
#2 /opt/work/assetor/vendor/yiisoft/yii2/base/BaseObject.php(109): kartik\detail\DetailView-&gt;init()
#3 [internal function]: yii\base\BaseObject-&gt;__construct()
#4 /opt/work/assetor/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass-&gt;newInstanceArgs()

I've taken a look into https://github.com/kartik-v/yii2-detail-view/blob/cdeb72a7b04d1e2cc7d7c67ebcba2ee27dd0fb17/src/DetailView.php#L812

protected function initWidget()
    {
        $this->_msgCat = 'kvdetail';
        $this->pluginName = 'kvDetailView';
        $this->initBsVersion();
        $notBs3 = !$this->isBs(3);
        if ($notBs3) {
            Html::addCssClass($this->container, 'kv-container-bs4');
        }

and as far is I've understood, this must be definded in the interface

https://github.com/kartik-v/yii2-krajee-base/blob/master/src/BootstrapInterface.php

but it doesnt' :-/

kartik-v commented 2 years ago

You need to update your packages via composer with all dependencies. You do not seem to have the latest release of dependencies like yii2-krajee-base which includes the various traits containing these methods which are shown on your app as missing.

strtob commented 2 years ago

Thanks a lot kartik!

I've tried to reinstall, incl. deps, also have installed manually via composer require "kartik-v/yii2-krajee-base": "dev-master" - without success :-/

strtob commented 2 years ago

...I've insert it here:

class DetailView extends YiiDetailView implements BootstrapInterface
{
    use WidgetTrait;
    use TranslationTrait;

    /**
     * @var string view mode for the detail view
     */
    const MODE_VIEW = 'view';

after translationTrait (use kartik\base\BootstrapTrait) which fix the problem...

chmoth-yii commented 2 years ago

I am also encountering same issue. tried adding "BootstrapTrait" like @strtob suggested and the error is gone. attaching reference code.

class DetailView extends YiiDetailView implements BootstrapInterface
{
    use WidgetTrait;
    use TranslationTrait;
    use BootstrapTrait; <---Manually added. this is Missing in latest version dev-master (1.8.5) thus causing the error

@kartik-v But will you be making an official fix for this soon? or are we doing something wrong?

By the way, Hats Off to you for all the effort in making all these wonderful widgets and plugins! Much Appreciated! Cant Thank you Enough.

kartik-v commented 2 years ago

Thanks this will be updated.

chmoth-yii commented 2 years ago

Thankyou very much for this Quick Reponse!