You are here

public function NestedTableDragTestForm::buildForm in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/tabledrag_test/src/Form/NestedTableDragTestForm.php \Drupal\tabledrag_test\Form\NestedTableDragTestForm::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 TableDragTestForm::buildForm

File

core/modules/system/tests/modules/tabledrag_test/src/Form/NestedTableDragTestForm.php, line 22

Class

NestedTableDragTestForm
Provides a form for testing nested draggable tables.

Namespace

Drupal\tabledrag_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $parent_row_ids = [
    'parent_1',
    'parent_2',
    'parent_3',
  ];
  $parent_rows = array_combine($parent_row_ids, $parent_row_ids);
  $form['table'] = $this
    ->buildTestTable($parent_rows, 'tabledrag-test-parent-table', 'tabledrag-test-nested-parent', FALSE);
  $form['table']['#caption'] = $this
    ->t('Parent table');
  $form['table'][reset($parent_row_ids)]['title'] = $this
    ->buildTestTable() + [
    '#caption' => $this
      ->t('Nested table'),
  ];
  $form['actions'] = $this
    ->buildFormActions();
  return $form;
}