Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap 4 #18

Open
dan8551 opened this issue Mar 28, 2020 · 3 comments
Open

Bootstrap 4 #18

dan8551 opened this issue Mar 28, 2020 · 3 comments

Comments

@dan8551
Copy link

dan8551 commented Mar 28, 2020

The module has the option to switch to Bootstrap V4 but due to dependencies, cannot properly perform as V3 support is still required which completely changes the layout, this is due to V3 and V4 being loaded on the same page.

Please can you change dependencies to V4 support?

@sjaakp
Copy link
Owner

sjaakp commented Apr 1, 2020 via email

@ettolo
Copy link

ettolo commented Apr 8, 2020

Hi sjakkp,
could you provide an example on how to use Yii::$container->setDefinitions
I'm getting errors of bootstrap dependency for example in/pluto/role/create:

Failed to instantiate component or class "yii\bootstrap\BootstrapAsset"
Caused by: ReflectionException
Class yii\bootstrap\BootstrapAsset does not exist
in /home/xxxx/vendor/yiisoft/yii2/di/Container.php at line 447

Thank you!

@rossaddison
Copy link
Contributor

rossaddison commented May 7, 2020

Have you installed "yiisoft/yii2-bootstrap": "*" and "yiisoft/yii2-bootstrap4 in your composer.json under the require section and updated composer?

The setDefinition function on Github

    public function setDefinitions(array $definitions)
{
    foreach ($definitions as $class => $definition) {
        if (is_array($definition) && count($definition) === 2 && array_values($definition) === $definition && is_array($definition[1])) {
            $this->set($class, $definition[0], $definition[1]);
            continue;
        }

        $this->set($class, $definition);               //set command
    }
}

As you can see it uses the set command here for each occurrence of a definition. If you are just wanting to setup one definition you can just use the set command. Where? In the first index file .. that sits in your root or web folder. This ensures that it will be implemented from the very beginning.

As Sjaak has suggested here I use the following command to overcome the GridView not displaying pagination css at the bottom according to issue 4 here using the following command in your index file.

    Yii::$container->set('yii\widgets\LinkPager', 'yii\bootstrap4\LinkPager');

index.php file

    (new yii\web\Application($config));

    Yii::$container->set('yii\widgets\LinkPager', 'yii\bootstrap4\LinkPager');

    Yii::$app->run();  

I initially thought that I would get around this issue by simply changing this extension's yii/grid/Gridview to kartik/grid/GridView which works but this does not help my extension which will be downloadable since it will inherit the bootstrap problem.

So my frontend/config/params section uses Bootstrap 4 as suggested by Kartik.

    'bsVersion' => '4.x',

However the old grid does not use Boostrap 4 and this Dependency Injection forces the LinkPager to use boostrap4 linkPager. Admittedly this is a quickfix and I have not had time to isolate the error in the code but this will do for me for the time being.

Further reading Kartik Dependency Injection

Istvan Duallistbox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants