Yii2 ZeroClipboard v2.x extension
The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface., (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist chornij/yii2-zeroclipboard "dev-master"
or add, (*4)
"chornij/yii2-zeroclipboard": "dev-master"
to the require section of your composer.json
file., (*5)
Usage
Once the extension is installed, simply use it in your code by :, (*6)
= chornij\zeroclipboard\Button::widget([
'label' => ' ' . \Yii::t('app', 'Copy'),
'encodeLabel' => false,
'text' => "$('.copy-selector').text()",
]) ?>
My text to copy!
Once clicked on Copy button it should change the status to Copied! If it does not change then make sure that your Flash Plugin is enabled in browser. If you are using Chrome check the following settings:
chrome://plugins/
and make sure that Adobe Flash Player plugin is enabled., (*7)