hestec / silverstripe-fieldcounter
Adds a counter to defined fields to show remaining characters
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-11-13 15:26:49 UTC
README
Shows a field counter on specified fields in the SilverStripe CMS
This is an update of the PlatoCreative fieldcounter: https://github.com/PlatoCreative/silverstripe-fieldcounter This repository has an updated folder structure and moves the css and js to the resources folder.
Usage
To add the field counter to a Silverstripe field in the CMS you need to add:
TextField::('myfield')->setAttribute('data-fieldcounter', 140);
If you require different limits change the 140. Note: Adding this to a TextareaField prevents new lines.
If you want to prevent more text than your limit, use the built in HTML attribute maxlength
e.g.
TextField::('myfield')->setAttribute('maxlength', 140);
Install
$ composer require hestec/silverstripe-fieldcounter:1.*