muetze42/nova-charcounted-fields

This package is abandoned and no longer maintained. No replacement package was suggested.

Text and textarea fields with a character counter.

1.0.0 2021-03-10 01:13 UTC

This package is auto-updated.

Last update: 2022-05-10 03:49:45 UTC


README

Text and textarea fields with a character counter for Laravel Nova.

Installation

You can require this package using composer:

composer require muetze42/nova-charcounted-fields

Usage

You can add the field with a resolver as follows:

use ElevateDigital\CharcountedFields\TextCounted;
use ElevateDigital\CharcountedFields\TextareaCounted;

TextCounted::make('Meta title')

You can use the text and textarea fields with charactercounters on you Nova model. The max number of characters aren't enforced, but just encouraged with warning colors and the counter. (You could enforce the max number of characters with Nova's built in rules and with a maxlength extra attribute).

TextCounted::make('Meta title')
    ->maxChars(60)
    ->warningAt(50)
    ->withMeta(['extraAttributes' => ['maxlength' => '65']]),

TextareaCounted::make('Meta description')
    ->maxChars(160)
    ->warningAt(150)
    ->rows(3),

The maxChars and warningAt are both optional. The color of the counter will change when the max or warningAt limit is reached.