yii2 a href confirm
The Yii framework provides a way to generate HTML links using the Html::a
method. To create a link with a confirmation message, you can use the confirm
parameter. Here's an example:
use yii\helpers\Html;
echo Html::a('Click me', ['controller/action'], [
'data' => [
'confirm' => 'Are you sure you want to proceed?',
'method' => 'post',
],
]);
This code will generate an HTML link with the text "Click me". When the link is clicked, a confirmation dialog will appear with the message "Are you sure you want to proceed?". If the user confirms, the link will perform a POST request to the specified controller action.
Please note that the confirmation dialog is a browser feature and may vary in appearance across different browsers.