kartik-v / yii2-datecontrol

Date control module allowing separation of date formats for View & Model for Yii Framework 2.0.
http://demos.krajee.com/datecontrol
Other
55 stars 29 forks source link

Calling unknown method kartik\datecontrol\DateControl::initBsVersion() #135

Closed r-valle-arca closed 4 years ago

r-valle-arca commented 4 years ago

Prerequisites

Steps to reproduce the issue

  1. Install the package using composer
  2. Setup datecontrol module
  3. Use it in a form

Expected behavior and actual behavior

When I follow those steps and I try to access this view in the browser, I see...

Unknown Method – yii\base\UnknownMethodException
Calling unknown method: kartik\datecontrol\DateControl::initBsVersion()

1. in (...)/vendor/yiisoft/yii2/base/Component.phpat line 290
281282283284285286287288289290291292293294295296297298299     */
    public function __call($name, $params)
    {
        $this->ensureBehaviors();
        foreach ($this->_behaviors as $object) {
            if ($object->hasMethod($name)) {
                return call_user_func_array([$object, $name], $params);
            }
        }
        throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
    }

    /**
     * This method is called after the object is created by cloning an existing one.
     * It removes all behaviors because they are attached to the old object.
     */
    public function __clone()
    {
        $this->_events = [];
2. in (...)/vendor/kartik-v/yii2-datecontrol/src/DateControl.php at line 295– yii\base\Component::__call('initBsVersion', [])
289290291292293294295296297298299300301            $this->widgetOptions['options']['id'] = $this->options['id'];
        }
        $this->_doTranslate = isset($this->language) && $this->language != 'en';
        if ($this->autoWidget && !isset($this->_widgetSettings[$this->type]['bsVersion']) && isset($this->bsVersion)) {
            $this->_widgetSettings[$this->type]['bsVersion'] = $this->bsVersion;
        }
        $this->initBsVersion();
        if ($this->_doTranslate && $this->autoWidget) {
            $this->_widgetSettings[$this->type]['options']['language'] = $this->language;
        }
        $this->setLocale();
    }

3. in (...)/vendor/kartik-v/yii2-datecontrol/src/DateControl.php at line 295–
An Error occurred while handling another error:
exception 'ReflectionException' with message 'Method kartik\datecontrol\DateControl::initBsVersion() does not exist' in (...)/vendor/yiisoft/yii2/web/ErrorHandler.php:199
Stack trace:
#0 (...)/vendor/yiisoft/yii2/web/ErrorHandler.php(199): ReflectionMethod->__construct('kartik\\datecont...', 'initBsVersion')
#1 (...)/vendor/yiisoft/yii2/views/errorHandler/callStackItem.php(26): yii\web\ErrorHandler->addTypeLinks('kartik\\datecont...')
#2 (...)/vendor/yiisoft/yii2/base/View.php(328): require('some route...')
#3 (...)/vendor/yiisoft/yii2/base/View.php(250): yii\base\View->renderPhpFile('some route...', Array)
#4 (...)/vendor/yiisoft/yii2/web/ErrorHandler.php(253): yii\base\View->renderFile('@yii/views/erro...', Array, Object(yii\web\ErrorHandler))
#5 (...)/vendor/yiisoft/yii2/web/ErrorHandler.php(308): yii\web\ErrorHandler->renderFile('@yii/views/erro...', Array)
#6 (...)/vendor/yiisoft/yii2/views/errorHandler/exception.php(385): yii\web\ErrorHandler->renderCallStackItem('some route...', 295, 'kartik\\datecont...', 'initBsVersion', Array, 3)
#7 (...)/vendor/yiisoft/yii2/base/View.php(328): require('some route...')
#8 (...)/vendor/yiisoft/yii2/base/View.php(250): yii\base\View->renderPhpFile('some route...', Array)
#9 (...)/vendor/yiisoft/yii2/web/ErrorHandler.php(253): yii\base\View->renderFile('@yii/views/erro...', Array, Object(yii\web\ErrorHandler))
#10 (...)/vendor/yiisoft/yii2/web/ErrorHandler.php(114): yii\web\ErrorHandler->renderFile('@yii/views/erro...', Array)
#11 (...)/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\base\UnknownMethodException))
#12 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\base\UnknownMethodException))
#13 {main}
Previous exception:
exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: kartik\datecontrol\DateControl::initBsVersion()' in (...)/vendor/yiisoft/yii2/base/Component.php:290
Stack trace:
#0 (...)/vendor/kartik-v/yii2-datecontrol/src/DateControl.php(295): yii\base\Component->__call('initBsVersion', Array)
#1 (...)/vendor/kartik-v/yii2-datecontrol/src/DateControl.php(295): kartik\datecontrol\DateControl->initBsVersion()
#2 (...)/vendor/yiisoft/yii2/base/Object.php(107): kartik\datecontrol\DateControl->init()
#3 [internal function]: yii\base\Object->__construct(Array)
#4 (...)/vendor/yiisoft/yii2/di/Container.php(381): ReflectionClass->newInstanceArgs(Array)
#5 (...)/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('kartik\\datecont...', Array, Array)
#6 (...)/vendor/yiisoft/yii2/BaseYii.php(344): yii\di\Container->get('kartik\\datecont...', Array, Array)
#7 (...)/vendor/yiisoft/yii2/base/Widget.php(136): yii\BaseYii::createObject(Array)
#8 (...)/vendor/yiisoft/yii2/widgets/ActiveField.php(725): yii\base\Widget::widget(Array)
#9 (...)/some_route/_form.php(46): yii\widgets\ActiveField->widget('kartik\\datecont...', Array)
#10 (...)/vendor/yiisoft/yii2/base/View.php(328): require('some route...')
#11 (...)/vendor/yiisoft/yii2/base/View.php(250): yii\base\View->renderPhpFile('some route...', Array)
#12 (...)/vendor/yiisoft/yii2/base/View.php(152): yii\base\View->renderFile('some route...', Array, NULL)
#13 (...)/some_route/create.php(22): yii\base\View->render('_form', Array)
#14 (...)/vendor/yiisoft/yii2/base/View.php(328): require('some route...')
#15 (...)/vendor/yiisoft/yii2/base/View.php(250): yii\base\View->renderPhpFile('some route...', Array)
#16 (...)/vendor/yiisoft/yii2/base/View.php(152): yii\base\View->renderFile('some route...', Array, Object(SomeController))
#17 (...)/vendor/yiisoft/yii2/base/Controller.php(381): yii\base\View->render('create', Array, Object(SomeController))
#18 (...)/some_route/SomeController.php(129): yii\base\Controller->render('create', Array)
#19 [internal function]: some_route/SomeController->actionCreate()
#20 (...)/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#21 (...)/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#22 (...)/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('create', Array)
#23 (...)/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('some_route...', Array)
#24 /home/chip2chip/intranet/intranet/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
#25 (...)/frontend/web/index.php(17): yii\base\Application->run()
#26 {main}

I was expecting being able of rendering the form that contains a date or time field correctly.

composer.json

{
    "name": "yiisoft/yii2-app-advanced",
    "description": "Yii 2 Advanced Project Template",
    "keywords": ["yii2", "framework", "advanced", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "~2.0.6",
        "yiisoft/yii2-bootstrap": "^2.0@dev",
        "yiisoft/yii2-swiftmailer": "^2.0@dev",
        "dektrium/yii2-user": "^0.9.12",
        "dektrium/yii2-rbac": "1.0.0-alpha@dev",
        "p2made/yii2-sb-admin-theme": "^2.4",
        "jcabanillas/yii2-inspinia": "*",
        "kartik-v/yii2-widget-datepicker": "@dev",
        "marqu3s/yii2-summernote": "dev-master",
        "sadovojav/yii2-image-thumbnail": "dev-master",
        "yii2mod/yii2-sweet-alert": "*",
        "tecnocen/yii2-bootstrap-year-calendar": "*",
        "raoul2000/yii2-workflow": "*",
        "cornernote/yii2-workflow-manager": "*",
        "raoul2000/yii2-workflow-view": "*",
        "kartik-v/yii2-widget-growl": "*",
        "kartik-v/yii2-grid": "@dev",
        "kartik-v/yii2-editable": "*",
        "kartik-v/yii2-number": "*",
        "kartik-v/yii2-widget-switchinput": "dev-master",
        "kartik-v/yii2-widgets": "dev-master",
        "kartik-v/yii2-krajee-base": "^1.9@dev",
        "kartik-v/yii2-helpers": "^1.3@dev",
        "kartik-v/yii2-field-range": "^1.3@dev",
        "kartik-v/yii2-nav-x": "^1.2@dev",
        "linslin/yii2-curl": "dev-master",
        "kartik-v/yii2-sortable-input": "*",
        "tecnickcom/tcpdf": "dev-master",
        "google/apiclient": "^2.0",
        "kartik-v/yii2-datecontrol": "dev-master"

    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.0.0",
        "yiisoft/yii2-gii": "^2.0",
        "yiisoft/yii2-faker": "~2.0.0",

        "codeception/base": "^2.2.3",
        "codeception/verify": "~0.3.1"
    },
    "config": {
        "process-timeout": 1800
    },
    "extra": {
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    },
    "scripts": {
        "post-install-cmd": "php init --env=Development --overwrite=n"
    }
}

datecontrol module setup in frontend/config/main.php:

use kartik\datecontrol\Module;
return [
     // (...)

     'modules' => [
          'datecontrol' => [
            'class' => 'kartik\datecontrol\Module',
            // format settings for displaying each date attribute 
            'displaySettings' => [
                Module::FORMAT_DATE => 'yyyy-MM-dd',
                Module::FORMAT_TIME => 'HH:mm:ss',
                Module::FORMAT_DATETIME => 'dd/MM/yyyy HH:mm:ss',
            ],
            'saveSettings' => [
                Module::FORMAT_DATE => 'php:U',
                Module::FORMAT_TIME => 'php:H:i:s',
                Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
            ],
            'autoWidget' => true,
            'ajaxConversion' => true,
        ],
      ],
];

Environment

Browsers

Operating System

Libraries

Isolating the problem

r-valle-arca commented 4 years ago

I close this issue because I think it is a coding question. I will post it at the forum.

r-valle-arca commented 4 years ago

For anyone who would find himself in a similar situation, I reinstalled the following packages to solve it:

composer require kartik-v/yii2-datecontrol "dev-master" 

output:
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Installing kartik-v/php-date-formatter (v1.3.6): Downloading (100%)
  - Installing kartik-v/yii2-krajee-base (v2.0.5): Downloading (100%)
  - Installing kartik-v/yii2-datecontrol (dev-master 0e7057f): Cloning 0e7057f644 from cache
kartik-v/yii2-krajee-base suggests installing yiisoft/yii2-bootstrap4 (for Krajee extensions to work with Bootstrap 4.x version)
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
13 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

composer require kartik-v/yii2-widget-timepicker "@dev"

output:

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing kartik-v/yii2-widget-timepicker (dev-master 27847bf): Cloning 27847bf0a3 from cache
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
13 packages you are using are looking for funding.
Use the `composer fund` command to find out more!