Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.
You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page
The TextWithLengthCounterType
represents text input with value length counter.
Option | Type | Default | Description |
---|---|---|---|
max_length | int | None, must be configured | Max length of input value |
position | string | before |
Configures position for counter. Available options are: before and after |
input | string | text |
Configured input type text or textarea |
Component | Description |
---|---|
TextWithLengthCounter | Calculates remaining length for input |
First, you have to add TextWithLengthCounterType
to your form.
<?php
use Symfony\Component\Form\AbstractType;
use PrestaShopBundle\Form\Admin\Type\TextWithLengthCounterType;
class SomeType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('meta_title', TextWithLengthCounterType::class, [
'max_length' => 255,
]);
}
}
Then in Javascript you have to enable TextWithLengthCounter
component.
import TextWithLengthCounter from "admin-dev/themes/new-theme/js/components/form/text-with-length-counter";
// enables length counter for all TextWithLengthCounterType inputs on the page
new TextWithLengthCounter();