jlorente/yii2-widget-remainingcharacters 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jlorente/yii2-widget-remainingcharacters

最新稳定版本:1.0.1

Composer 安装命令:

composer require jlorente/yii2-widget-remainingcharacters

包简介

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

README 文档

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

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.

统计信息

  • 总下载量: 33.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-02