You are here

public function FormTestTableForm::buildForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/form_test/src/Form/FormTestTableForm.php \Drupal\form_test\Form\FormTestTableForm::buildForm()

Form constructor.

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 The form structure.

Overrides FormInterface::buildForm

File

core/modules/system/tests/modules/form_test/src/Form/FormTestTableForm.php, line 24
Contains \Drupal\form_test\Form\FormTestTableForm.

Class

FormTestTableForm

Namespace

Drupal\form_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['table'] = [
    '#type' => 'table',
    '#tableselect' => TRUE,
    '#empty' => $this
      ->t('Empty text.'),
  ];
  $form['table']['row'] = [
    'data' => [
      '#title' => '<em>kitten</em>',
      '#markup' => '<p>some text</p>',
    ],
  ];
  $form['table']['another_row'] = [
    'data' => [
      '#title' => $this
        ->t('my favourite fruit is <strong>@fruit</strong>', [
        '@fruit' => 'bananas',
      ]),
      '#markup' => '<p>some more text</p>',
    ],
  ];
  return $form;
}