runopencode / dm-char-count-plugin
该软件包已被废弃且不再维护。未建议替代软件包。
dmCharCountPlugin - Diem Extended 的 CharCount TextArea
dev-master
2012-11-24 00:00 UTC
Requires
- composer/installers: dev-master
This package is auto-updated.
Last update: 2022-02-01 12:22:24 UTC
README
作者: TheCelavi
版本: 1.0.0
稳定性: 稳定
日期: 2012年11月10日
由 Run Open Code 提供
许可: 免费
dmCharCountPlugin 可将您的文本区域转换为字符计数字段。
您可以在管理后台、前端以及表单中使用此小部件。
- 要在管理后台中添加此字段,请将 schema.yml 中的您的字段添加
extra: charcount
示例
Testobj:
actAs:
DmSortable:
columns:
title: { type: string(255), notnull: true }
is_active: { type: boolean, notnull: true, default: false }
meta_keywords: { type: string(255), notnull: true }
meta_description: { type: string(255), notnull: true, extra: charcount }
在您类的基形式中,将使用表单小部件: new sfWidgetFormDmCharCountTextarea()
。
您可以通过 config.yml
和在类的构造函数中传递选项的几种不同方式来配置此小部件。
配置选项
allowed
, int, 默认 255,允许的最大字符数。warning
, int 或百分比,默认为 10%,在超过最大字符数时应警告的字符数。当您希望用户收到警告时,可以输入确切的字符数。counterText
, string,默认为 'Characters left:'。字符串在渲染之前会被翻译。
在 config.yml
中是此小部件的默认设置
default:
dmCharCountPlugin:
all:
allowed: 255
warning: 10%
counterText: 'Characters left:'
all
是针对所有表单小部件的默认配置。您可以添加表单字段的名称以进行额外配置。
例如,对于 config.yml
default:
dmCharCountPlugin:
all:
allowed: 255
warning: 10%
counterText: 'Characters left:'
my_form[my_field]:
allowed: 500
当然,您也可以在部件的构造函数中传递选项
new sfWidgetFormDmCharCountTextarea(array(
'allowed' => 255,
'warning' => '10%',
'counterText' => 'Characters left:'
))
配置的重要性
- 构造函数
- 通过名称为特定表单小部件配置
- 为所有表单小部件配置