hestec / silverstripe-fieldcounter
为指定的字段添加计数器,以显示剩余字符数
2.0.1
2024-02-13 13:47 UTC
Requires
- silverstripe/cms: >=5.0
- silverstripe/framework: >=5.0
This package is auto-updated.
Last update: 2024-09-13 15:02:55 UTC
README
在SilverStripe CMS的指定字段上显示字段计数器
这是PlatoCreative fieldcounter的更新:https://github.com/PlatoCreative/silverstripe-fieldcounter 此存储库具有更新的文件夹结构和将css和js移动到资源文件夹。
使用方法
要在CMS中将字段计数器添加到Silverstripe字段,您需要添加
TextField::('myfield')->setAttribute('data-fieldcounter', 140);
如果您需要不同的限制,请更改140。注意:将此添加到TextareaField将防止换行。
如果您想防止超过限制的文本,请使用内置的HTML属性maxlength
,例如。
TextField::('myfield')->setAttribute('maxlength', 140);
安装
$ composer require hestec/silverstripe-fieldcounter:1.*