M
M
Mikhail Shatilov2014-10-22 21:56:22
Yii
Mikhail Shatilov, 2014-10-22 21:56:22

How to disable automatic js insertion in Yii2?

Using, for example, ActiveForm, js is automatically inserted
wRmzXyzJIPERAO.jpg

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Roman Zhuravlev, 2014-10-23
@Zhuravljov

<?php $form = ActiveForm::begin(['enableClientScript' => false]); ?>

S
Sergey, 2014-10-22
@TsarS

You need to disable them in AssetBundle

M
Mikhail Shatilov, 2014-10-22
@iproger

Disabled in AssetBundle:

public $depends = [
    //'yii\web\YiiAsset',
    //'yii\bootstrap\BootstrapAsset',
  ];

I also tried to disable it in the config:
'assetManager' => [
      'bundles' => [
        'yii\bootstrap\BootstrapAsset' => [
          'basePath' => '@webroot',
          'baseUrl' => '/',
          'css' => [],
          'js' => [],
          'sourcePath' => null,
        ],
        'yii\web\JqueryAsset' => [
          'sourcePath' => null,
          'js' => [],
        ],
        'yii\web\BootstrapPluginAsset' => [
          'sourcePath' => null,
          'js' => [],
        ],
      ],
    ],

D
Dmitry, 2019-02-28
@dmitrytyt

You can disable one or more resource bundles by associating false with the names of the resource bundles you want to disable.
Setting Up Resource Kits

'assetManager' => [
     'bundles' => [
          JqueryAsset::class => false,
          YiiAsset::class => false,
          ActiveFormAsset::class => false
     ],
     // 'bundles' => false
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question