jlorente / yii2-widget-remainingcharacters
Widget to add a remaining character counter to text inputs and textareas
Installs: 29 484
Dependents: 2
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 3
Open Issues: 0
Type:yii2-extension
Requires
- bower-asset/jquery-remaining-characters: ~1.0.0
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-11-10 05:14:09 UTC
README
RemainingCharacters widget is a Yii2 wrapper for the jquery-remaining-characters jQuery plugin Remaining Characters jQuery plugin. This input widget is a replacement for text and textarea inputs. It appends a container with a countdown counter of characters to the input.
Installation
The preferred way to install this extension is through composer. Check the composer.json for this extension's requirements and dependencies.
To install, either run
$ php composer.phar require jlorente/yii2-widget-remainingcharacters "*"
or add
... "require": { ... "jlorente/yii2-widget-remainingcharacters": "*" }
to the require
section of your composer.json
file.
Usage
use jlorente\remainingcharacters\RemainingCharacters; // echo $form->field($model, 'my-textarea')->widget(RemainingCharacters::classname(), [ 'type' => RemainingCharacters::INPUT_TEXTAREA, 'text' => Yii::t('app', '{n} characters remaining'), 'label' => [ 'tag' => 'p', 'id' => 'my-counter', 'class' => 'counter', 'invalidClass' => 'error' ], 'options' => [ 'rows' => '3', 'class' => 'col-md-12', 'maxlength' => 200, 'placeholder' => Yii::t('app', 'Write something') ] ]);
Where options array are the options for the textarea.
Options
License
Copyright © 2015 José Lorente Martín. Licensed under the MIT license. See LICENSE.txt for details.