function FormTestTableSelectDisabledRowsForm::buildForm

Same name in other branches
  1. 10 core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectDisabledRowsForm.php \Drupal\form_test\Form\FormTestTableSelectDisabledRowsForm::buildForm()
  2. 11.x core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectDisabledRowsForm.php \Drupal\form_test\Form\FormTestTableSelectDisabledRowsForm::buildForm()

Overrides FormInterface::buildForm

File

core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectDisabledRowsForm.php, line 24

Class

FormTestTableSelectDisabledRowsForm
Builds a form to test table select with disabled rows.

Namespace

Drupal\form_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $test_action = NULL) {
    $multiple = [
        'multiple-true' => TRUE,
        'multiple-false' => FALSE,
    ][$test_action];
    $form = $this->tableselectFormBuilder($form, $form_state, [
        '#multiple' => $multiple,
        '#js_select' => TRUE,
        '#ajax' => NULL,
    ]);
    // Disable the second row.
    $form['tableselect']['#options']['row2']['#disabled'] = TRUE;
    return $form;
}

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