Yii2: confirm prompt coming twice with yii2 latest version

Created on 9 Jan 2017  路  10Comments  路  Source: yiisoft/yii2

', ['add/remove-img','id'=>$file->id], [ 'data' => [ 'method' => 'post', 'confirm' => 'Confirm msg' ], ] )?>

now this is the issue with ref with #6642 here confirm prompt coming twice..

JS

All 10 comments

Thanks for posting in our issue tracker.
In order to properly assist you, we need additional information:

  • When does the issue occur?
  • What do you see?
  • What was the expected result?
  • Can you supply us with a stacktrace? (optional)
  • Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)

Thanks!

_This is an automated comment, triggered by adding the label status:need more info._

When does the issue occur?

  • when trying to generate confirm prompt on HTML::a tag using data['confirm']

What do you see?

  • prompt shows twice. once i click on then again shows same prompt

What was the expected result?

  • it should work only once.

So it's just HTML::a without any form tags or PJAX?

yes its just HTML::a tag in but yes its in form but not with $form object.

Then please edit 1st post to contain full example on how to reproduce it. Thanks.

My code for "delete" button in ActionColumn:

'delete' => function ($url, $model, $key) {
                            $url = \yii\helpers\Url::to(['/url/delete', 'id' => $model->id]);

                            return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
                                'title' => '校写邪谢懈褌褜',
                                'class' => 'btn btn-sm btn-default',
                                'data-method' => 'post',
                                'data-pjax' => 1,
                                'data-confirm' => '袙褘 褍胁械褉械薪褘, 褔褌芯 褏芯褌懈褌械 褍写邪谢懈褌褜 褝褌芯 锌褉邪胁懈谢芯?',
                            ]);
                        },

If i put a grid in the form (ActiveForm) - prompt coming twice.
Without "form" around grid - prompt appears only once.

One more thing. Are you able to reproduce the same issue using code from master branch?

<?php $form = ActiveForm::begin([
        'action' => 'clone',
        'method' => 'POST',
    ]); ?>
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'columns' => [
                        ['class' => 'yii\grid\SerialColumn'],
                        'Descripcion',
                        [
                            'class' => 'yii\grid\CheckboxColumn',
                            'multiple' => true
                        ],
                    ],
                ]); ?>
        <div class="form-group">
            <?= Html::submitButton('Duplicar preguntas seleccionadas', [
                'class' => 'btn btn-success',
                'data' => [
                    'confirm' => '驴Est谩 seguro?',
                ],
            ]) ?>
        </div>
    <?php ActiveForm::end(); ?>

Same problem without PJAX... v2.0.10

Hi, having the same issue since 2.0.10

You need to place your link with data-confirm attribute INSIDE yii ActiveForm to reproduce this bug.
So the click event and confirm dialog seem to be fired twice after that.

Closing this issue as a duplicate of #13255.
Please, visit issue #13255 to continue conversation

Was this page helpful?
0 / 5 - 0 ratings