Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php \Drupal\form_test\Form\FormTestTableSelectFormBase::tableselectFormBuilder()
  2. 9 core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php \Drupal\form_test\Form\FormTestTableSelectFormBase::tableselectFormBuilder()

Build a form to test the tableselect element.

Parameters

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

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

$element_properties: An array of element properties for the tableselect element.

Return value

array A form with a tableselect element and a submit button.

5 calls to FormTestTableSelectFormBase::tableselectFormBuilder()
FormTestTableSelectColspanForm::buildForm in core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php
Form constructor.
FormTestTableSelectDisabledRowsForm::buildForm in core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectDisabledRowsForm.php
Form constructor.
FormTestTableSelectEmptyForm::buildForm in core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php
Form constructor.
FormTestTableSelectMultipleFalseForm::buildForm in core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php
Form constructor.
FormTestTableSelectMultipleTrueForm::buildForm in core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php
Form constructor.

File

core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php, line 28

Class

FormTestTableSelectFormBase
Provides a base class for tableselect forms.

Namespace

Drupal\form_test\Form

Code

public function tableselectFormBuilder($form, FormStateInterface $form_state, $element_properties) {
  [
    $header,
    $options,
  ] = _form_test_tableselect_get_data();
  $form['tableselect'] = $element_properties;
  $form['tableselect'] += [
    '#prefix' => '<div id="tableselect-wrapper">',
    '#suffix' => '</div>',
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#multiple' => FALSE,
    '#empty' => t('Empty text.'),
    '#ajax' => [
      'callback' => 'form_test_tableselect_ajax_callback',
      'wrapper' => 'tableselect-wrapper',
    ],
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => t('Submit'),
  ];
  return $form;
}