3 namespace Drupal\form_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Provides a base class for tableselect forms.
11 abstract class FormTestTableSelectFormBase extends FormBase {
14 * Build a form to test the tableselect element.
17 * An associative array containing the structure of the form.
18 * @param \Drupal\Core\Form\FormStateInterface $form_state
19 * The current state of the form.
20 * @param $element_properties
21 * An array of element properties for the tableselect element.
24 * A form with a tableselect element and a submit button.
26 public function tableselectFormBuilder($form, FormStateInterface $form_state, $element_properties) {
27 list($header, $options) = _form_test_tableselect_get_data();
29 $form['tableselect'] = $element_properties;
31 $form['tableselect'] += [
32 '#prefix' => '<div id="tableselect-wrapper">',
33 '#suffix' => '</div>',
34 '#type' => 'tableselect',
36 '#options' => $options,
38 '#empty' => t('Empty text.'),
40 'callback' => 'form_test_tableselect_ajax_callback',
41 'wrapper' => 'tableselect-wrapper',
47 '#value' => t('Submit'),