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.
13 abstract class FormTestTableSelectFormBase extends FormBase {
16 * Build a form to test the tableselect element.
19 * An associative array containing the structure of the form.
20 * @param \Drupal\Core\Form\FormStateInterface $form_state
21 * The current state of the form.
22 * @param $element_properties
23 * An array of element properties for the tableselect element.
26 * A form with a tableselect element and a submit button.
28 public function tableselectFormBuilder($form, FormStateInterface $form_state, $element_properties) {
29 list($header, $options) = _form_test_tableselect_get_data();
31 $form['tableselect'] = $element_properties;
33 $form['tableselect'] += [
34 '#prefix' => '<div id="tableselect-wrapper">',
35 '#suffix' => '</div>',
36 '#type' => 'tableselect',
38 '#options' => $options,
40 '#empty' => t('Empty text.'),
42 'callback' => 'form_test_tableselect_ajax_callback',
43 'wrapper' => 'tableselect-wrapper',
49 '#value' => t('Submit'),