skip to Main Content

Then I don’t use yii confirmation dialog i can see submit button’s name and value in post request.
If I use yii confirmation dialog i can’t see submit button’s name and value in post request.

How to see them when yii confirmation dialog is used?

For example, if form contains such button:

<?= Html::submitButton('name', ['name' => 'action', 'value' => 'submitButtonValue']); ?>

It will have such post attributes:

 ["action"]=> string(12) "submitButtonValue"

On the other hand, if form contains button with yii confirmation dialog:

<?= Html::submitButton('name', ['name' => 'action', 'value' => 'submitButtonValue',
                            'data' => [
                                'confirm' => 'Are you sure?',
                                'method' => 'post'
                            ],
]); ?>

It wont contain "action=>’submitButtonValue’" attribute in the post request.

I tried to put name and value in data section, but it did not help.

'data' => [
   'confirm' => 'Are you sure?',
   'method' => 'post',
   'name' => 'action',
   'value' => 'submitButtonValue'
],

2

Answers


  1. This worked for me, writing the data-attributes explicitly:

    <?= Html::submitButton('name', [
               'name' => 'action', 
               'value' => 'submitButtonValue', 
               'data-confirm' => 'Are you sure?', 
               'data-method' => 'post',
        ]); ?>
    
    Login or Signup to reply.
  2. You can add a hiddenInput to your form.

        <?= Html::hiddenInput('action', ['value' => 'submitButtonValue']); ?>
        <?= Html::submitButton('name', ['data' => [
                  'confirm' =>'Are you sure?',  
                  'method' => 'post',
                  ]]); ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search