You are here

public function WebformCustomComposite::preview in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformCustomComposite.php \Drupal\webform\Plugin\WebformElement\WebformCustomComposite::preview()

Generate a renderable preview of the element.

Return value

array A renderable preview of the element.

Overrides WebformElementBase::preview

File

src/Plugin/WebformElement/WebformCustomComposite.php, line 162

Class

WebformCustomComposite
Provides a custom composite element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function preview() {
  return [
    '#type' => $this
      ->getTypeName(),
    '#title' => $this
      ->getPluginLabel(),
    '#element' => [
      'name' => [
        '#type' => 'textfield',
        '#title' => 'Name',
        '#title_display' => 'invisible',
      ],
      'sex' => [
        '#type' => 'select',
        '#title' => 'Sex',
        '#title_display' => 'invisible',
        '#options' => [
          'Male' => $this
            ->t('Male'),
          'Female' => $this
            ->t('Female'),
        ],
      ],
    ],
  ];
}