sandritsch91 / yii2-widget-autosize
An autosize widget for yii2
Installs: 87
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=8.0
- bower-asset/autosize: ^4.0.0 | ^5.0.0 | ^6.0.0
- yiisoft/yii2: ^2.0.20
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-16 13:06:28 UTC
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist sandritsch91/yii2-widget-autosize
or add
"sandritsch91/yii2-widget-autosize": "*"
to the require section of your composer.json
Usage
with a model:
use sandritsch91\yii2-widget-autosize\Autosize; echo Autosize::widget([ 'model' => $model, // The model to be used in the form 'attribute' => 'content', // The attribute to be used in the form 'htmlClass' => yii\bootstrap5\Html::class, // Optional. The class used to generate the form field 'clientEvents' => [ // Optional. Pass the client events to be attached to the textarea 'autosize:resized' => 'function() { console.log("resized"); }' ] ]);
with an ActiveForm:
use sandritsch91\yii2-widget-autosize\Autosize; echo $form->field($model, 'content')->widget(Autosize::class, [ 'clientEvents' => [ 'autosize:resized' => 'function() { console.log("resized"); }' ] ]);
without a model:
use sandritsch91\yii2-widget-autosize\Autosize; echo Autosize::widget([ 'name' => 'myText', // The name of the input 'value' => 'Hello World', // The value of the input 'clientEvents' => [ 'autosize:resized' => 'function() { console.log("resized"); }' ] ]);
Widget options
- clientEvents: The client events to be attached to the textarea. Defaults to []
- autosize:resized: Triggered when the textarea is resized
- autosize:update: Dispatch this event to update the textarea. No event is triggered by the plugin
- autosize:destroy: Dispatch this event to destroy the textarea. No event is triggered by the plugin
- htmlClass: The class used to generate the form field. Defaults to yii\helpers\Html::class