NestedTableDragTestForm.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/tabledrag_test/src/Form/NestedTableDragTestForm.php
  2. 11.x core/modules/system/tests/modules/tabledrag_test/src/Form/NestedTableDragTestForm.php

Namespace

Drupal\tabledrag_test\Form

File

core/modules/system/tests/modules/tabledrag_test/src/Form/NestedTableDragTestForm.php

View source
<?php

namespace Drupal\tabledrag_test\Form;

use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a form for testing nested draggable tables.
 */
class NestedTableDragTestForm extends TableDragTestForm {
    
    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'nested_tabledrag_test_form';
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }

}

Classes

Title Deprecated Summary
NestedTableDragTestForm Provides a form for testing nested draggable tables.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.