<?php

use \yii\helpers\Html;
use \yii\helpers\Url;

$script =<<< JS

$('.copy-link-btn').click(function(e){
    e.preventDefault();
    var url = $('#link-input');
    url.select();
    document.execCommand('copy');
});

JS;

$this->registerJs($script);

?>

<div>
    <div class="form-group">
        <label for=""><?= 'Campaign Generated Link' ?></label>

        <?= Html::textInput('link', Url::base(true) . $model->generatedLink, ['readOnly' => true, 'class' => 'form-control', 'id' => 'link-input']) ?>
    </div>

    <p>
        <?= Html::a('Copy Link', [''], ['class' => 'btn btn-purple btn-expanded copy-link-btn']) ?>
        <?= Html::button('Close', ['class' => 'btn btn-default btn-expanded', 'data-dismiss' => 'modal']) ?>
    </p>
</div>