2017 © Pedro PelĂĄez
 

yii2-extension yii2-widget-remainingcharacters

Widget to add a remaining character counter to text inputs and textareas

image

jlorente/yii2-widget-remainingcharacters

Widget to add a remaining character counter to text inputs and textareas

  • Tuesday, March 17, 2015
  • by jlorente
  • Repository
  • 1 Watchers
  • 2 Stars
  • 6,223 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 3 Versions
  • 3 % Grown

The README.md

Yii2 Remaining Characters Widget

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., (*1)

Installation

The preferred way to install this extension is through composer. Check the composer.json for this extension's requirements and dependencies., (*2)

To install, either run, (*3)

$ php composer.phar require jlorente/yii2-widget-remainingcharacters "*"

or add, (*4)

...
    "require": {
        ...
        "jlorente/yii2-widget-remainingcharacters": "*"
    }

to the require section of your composer.json file., (*5)

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., (*6)

Options

Option Type Default Description
type string RemainingCharacters::INPUT_TEXTAREA Type of the input. Must be RemainingCharacters::INPUT_TEXTAREA or RemainingCharacters::INPUT_TEXT
text string '{n}' Text to display inside the label where {n} is the placeholder of the remaining characters counter. i.e.: '{n} characters remaining'
label array Options related to the label container
label.tag string 'p' Html tag of the label
label.id string null Id of the label
label.class string 'char-counter' Class of the label
label.invalidClass string 'error' Class to add to the label if the counter reaches an invalid number
options array Options for the input text or textarea. See ActiveField::textarea() or ActiveField::textInput() for more information

License

Copyright © 2015 José Lorente Martín. Licensed under the MIT license. See LICENSE.txt for details., (*7)

The Versions

17/03 2015

dev-master

9999999-dev https://github.com/jlorente/yii2-widget-remainingcharacters

Widget to add a remaining character counter to text inputs and textareas

  Sources   Download

MIT

The Requires

 

by Jose Lorente Martin

textarea text input counter remaining characters

17/03 2015

1.0.1

1.0.1.0 https://github.com/jlorente/yii2-widget-remainingcharacters

Widget to add a remaining character counter to text inputs and textareas

  Sources   Download

MIT

The Requires

 

by Jose Lorente Martin

textarea text input counter remaining characters

02/03 2015

1.0.0

1.0.0.0 https://github.com/jlorente/yii2-widget-remainingcharacters

Widget to add a remaining character counter to text inputs and textareas

  Sources   Download

MIT

The Requires

 

by Jose Lorente Martin

textarea text input counter remaining characters