You are here

public function Table::form in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/Table.php \Drupal\webform\Plugin\WebformElement\Table::form()

Gets the actual configuration webform array to be built.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array An associative array contain the element's configuration webform without any default values.

Overrides WebformElementBase::form

File

src/Plugin/WebformElement/Table.php, line 172

Class

Table
Provides a 'table' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $form['table'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Table settings'),
  ];
  $form['table']['header'] = [
    '#title' => $this
      ->t('Header (YAML)'),
    '#type' => 'webform_codemirror',
    '#mode' => 'yaml',
  ];
  $form['table']['empty'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Empty text'),
    '#description' => $this
      ->t('Text to display when no rows are present.'),
  ];

  // Unset textarea rows to prevent any conflicts.
  unset($form['form']['size_container']['rows']);
  return $form;
}