1

I am using Html::submitButton for a delete button and I need a confirm message after pressing the delete button.

<?= Html::submitButton('Delete', ['name' => 'delete', 'value' => 0, 'id' => 'delete1', 'class' => 'pull-left btn btn-danger']) ?>

Does anyone know how to do that?

0

1 Answer 1

1

Try below code:

<?= Html::submitButton('Delete', ['name' => 'delete', 'value' => 0, 'id' => 'delete1', 'class' => 'pull-left btn btn-danger', 'data-confirm' => 'Are you sure you want to delete this item?']) ?>

Or

<?= Html::submitButton('Delete', ['name' => 'delete', 'value' => 0, 'id' => 'delete1', 'class' => 'pull-left btn btn-danger', 'confirm' => 'Are you sure you want to delete this item?']) ?>
Sign up to request clarification or add additional context in comments.

6 Comments

I can do that only in 2 minutes :)
Upps..It didn't worked :( I mean, it asks the confirm question, but when I press "ok", it doesn't delete the item.
Did you try both?
Try it: 'onclick'=>"return confirm('Confirm, please.')"
Yeah, I guess this works with 'onclick'. I am going to check it again.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.