yii2-iflclipboardjs
Foked from supplyhog/yii2-clipboardjs, (*1)
An easy way to use Clipboardjs in your project. Clipboardjs is a javascript only way to copy text to the clipboard., (*2)
Installation
Install this extension via composer. Add this line to your projectâs composer.json, (*3)
"israel/yii2-iflclipboardjs" : "dev-master"
Usage
//Button to copy text
= \supplyhog\ClipboardJs\ClipboardJsWidget::widget([
'text' => "Hello World",
// 'label' => 'Copy to clipboard',
// 'htmlOptions' => ['class' => 'btn'],
// 'tag' => 'button',
]) ?>
//Button to copy text from input id
= \supplyhog\ClipboardJs\ClipboardJsWidget::widget([
'inputId' => "#input-url",
// 'cut' => false, // Cut the text out of the input instead of copy?
// 'label' => 'Copy to clipboard',
// 'htmlOptions' => ['class' => 'btn'],
// 'tag' => 'button',
]) ?>
Just the Asset?
Yes, you can use just the asset. php \supplyhog\ClipboardJs\ClipboardJsAsset::register($view)
It will auto init anything with the "clipboard-js-init" class., (*4)