Giter Site home page Giter Site logo

yii2-widget-remainingcharacters's Introduction

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.

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

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.

yii2-widget-remainingcharacters's People

Contributors

jlorente avatar

Stargazers

Jonas Zumkehr avatar David Ochoa avatar lutek avatar Paul Kofmann avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

yii2-widget-remainingcharacters's Issues

height of textfield

Hello, i try to use yii2-widget-remainingcharacters widget in _form.php for TextIput field. I use: 'type' => \jlorente\remainingcharacters\RemainingCharacters::INPUT_TEXTAREA.

The height of rendered field is differed from height for standard yii2 fields. Help me please solve this issue.

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.