You are here

protected function MessageTemplateMultipleTextField::singleElement in Message 8

Return a single text area element.

Parameters

int $delta: Delta for the element.

array $text: Array containing 'value' and optionally 'format' for a text_format element.

Return value

array A single form element.

1 call to MessageTemplateMultipleTextField::singleElement()
MessageTemplateMultipleTextField::textField in src/FormElement/MessageTemplateMultipleTextField.php
Return the message text element.

File

src/FormElement/MessageTemplateMultipleTextField.php, line 113

Class

MessageTemplateMultipleTextField
Helper class to construct a multiple text field form.

Namespace

Drupal\message\FormElement

Code

protected function singleElement($delta, array $text) {
  $element = [
    '#type' => 'text_format',
    '#format' => isset($text['format']) ? $text['format'] : filter_default_format(),
    '#default_value' => $text['value'],
    '#rows' => 1,
  ];
  $element['_weight'] = [
    '#type' => 'weight',
    '#title' => t('Weight for row @number', [
      '@number' => $delta + 1,
    ]),
    '#title_display' => 'invisible',
    // Note: this 'delta' is the FAPI #type 'weight' element's property.
    '#delta' => $delta,
    '#default_value' => $delta,
  ];
  return $element;
}