FormTestTableSelectDisabledRowsForm.php

Same filename and directory in other branches
  1. 9 core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectDisabledRowsForm.php
  2. 10 core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectDisabledRowsForm.php

Namespace

Drupal\form_test\Form

File

core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectDisabledRowsForm.php

View source
<?php

declare (strict_types=1);
namespace Drupal\form_test\Form;

use Drupal\Core\Form\FormStateInterface;

/**
 * Builds a form to test table select with disabled rows.
 *
 * @internal
 */
class FormTestTableSelectDisabledRowsForm extends FormTestTableSelectFormBase {
  
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return '_form_test_tableselect_disabled_rows_form';
  }
  
  /**
   * {@inheritdoc}
   */
  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;
  }
  
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
  }

}

Classes

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

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