public function TextareaWithSummaryAndCounterWidget::addSummaryMaxlengthSettingsFormElement in Textfield Counter 8
Adds a form element to set maximum number of summary characters allowed.
Parameters
array $form: The form render array to which the element should be added.
File
- src/
Plugin/ Field/ FieldWidget/ TextareaWithSummaryAndCounterWidget.php, line 178
Class
- TextareaWithSummaryAndCounterWidget
- Plugin implementation of the 'text_textarea_with_summary_and_counter' widget.
Namespace
Drupal\textfield_counter\Plugin\Field\FieldWidgetCode
public function addSummaryMaxlengthSettingsFormElement(array &$form) {
$form['summary_maxlength'] = [
'#type' => 'number',
'#title' => $this
->t('Maximum number of characters in the summary'),
'#min' => 0,
'#default_value' => $this
->getSetting('summary_maxlength'),
'#description' => $this
->t('Setting this value to zero will disable the counter on the summary.'),
'#weight' => -69,
'#states' => [
'visible' => [
'[data-textfield-counter-selector="enable-summary-checkbox"]' => [
'checked' => TRUE,
],
],
],
];
}