1

Problem (see title)

Yii2: Replace default confirmation message used by Gridview with Sweet alert describes the initial problem and the fix that used to work. Now the fix no longer works. Something has changed in either bootstrap or kartik yii2-dialog that makes the work around for sweetalert in yii2 no longer a working workaround. :-)

The js/yii_overrides.js is loaded in, but the function are not used by yii’s event handler.

The javascript functions for ‘confirm’ that is used by the yii event handler points to yii2-dialog (kartik).

This can be found by running console.log(window.yii); when the document is ready.

Question: How does one disable kartik-v/yii2-dialog?

(the packages is required in composer by yii2-detail-view, yii2-grid and yii2-tree-manager (all kartik versions) as revealed by composer why kartik-v/yii2-dialog)

Perhaps disabling yii2-dialog is not the best solution to the problem, input is more than welcome. :-)

System:

Yii2-advanced app PHP Version 7.2.11 Yii Version 2.0.17-dev sweetalert Version 1.1.3 kartik-v/yii2-dialog Version 1.05

Tried:

Yii2: Replace default confirmation message used by Gridview with Sweet alert

When yii\bootstrap\BootstrapPluginAsset’ => [‘js’=>[]], is added to bundles in assetManager in components in (common\config\main.php) The result is the desired sweetalert alert message, but then bootstrap modal and other things from bootstrap stop working. If that line is not added then only the bootstrap alert message box comes up, and not the sweetalert message box.

(the line used above was taken from the following stackoverflow: Yii2 disable Bootstrap Js, JQuery and CSS ) Thank you for your time. Any help or pointers would be greatly appreciated.

aalesund
  • 313
  • 1
  • 4
  • 13
  • I have answered this question and I am currently using sweetalert as default confirmation message with the latest Yii version what I am currently trying to understand here is that are you having the problem in replacing the Yii's default confirmation message or the `kartik/yii2-dialog`? and what version of sweetalert are you using? – Muhammad Omer Aslam Feb 27 '19 at 19:42
  • and why are you trying to override the bootstrapPlugin asset ? if you have a live url where you are having the problem it might help to understand what error you are having, as the default `yii.js` class has the confirm method which is being overridden in the solution there – Muhammad Omer Aslam Feb 27 '19 at 19:45
  • @MuhammadOmerAslam Thank you for your comments. Q: 'How does one disable kartik-v/yii2-dialog?' Sweetalert: 'sweetalert Version 1.1.3 ' overide (or more precise: disable) bootstrapplugin asset was one of the things tried to get sweetalert to show. It did work, but it is not the desired solution for obvious reasons – aalesund Feb 28 '19 at 06:45
  • what i am saying is that if you want the sweet alert to work as the default prompt why are you even using the `kartik\yii2-dialog` just override the default `yii.confirm` as given in the answer and include the sweet alert assets to use as the default confirmation dialog, what is the point of first installing the `yii2-dialog` and then overriding it with sweet alert? – Muhammad Omer Aslam Feb 28 '19 at 08:57
  • kartik\yii2-dialog is in no way desired, it has not been chose for installation, but is a requirement of three packages that are currently in use. This is written in the question already: '(the packages is required in composer by yii2-detail-view, yii2-grid and yii2-tree-manager (all kartik versions) as revealed by composer why kartik-v/yii2-dialog)' @MuhammadOmerAslam Thank you again for your response. – aalesund Feb 28 '19 at 09:01
  • @MuhammadOmerAslam Similar problem here: https://stackoverflow.com/questions/55118032/how-to-disable-override-dependencies-in-yii2 – aalesund Mar 12 '19 at 13:25

1 Answers1

0

in frontend bootstrap.php:

\Yii::$container->set('kartik\dialog\Dialog', ['overrideYiiConfirm' => false]);

it is a global override.

aalesund
  • 313
  • 1
  • 4
  • 13