hestec/silverstripe-fieldcounter

Adds a counter to defined fields to show remaining characters

Installs: 16

Dependents: 1

Suggesters: 0

Security: 0

Type:silverstripe-vendormodule

2.0.1 2024-02-13 13:47 UTC

This package is auto-updated.

Last update: 2024-04-13 14:13:21 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.*