FormTestTableSelectFormBase.php in Drupal 10
File
core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
View source
<?php
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
abstract class FormTestTableSelectFormBase extends FormBase {
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;
}
}