Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestTableSelectFormBase.php
1 <?php
2
3 namespace Drupal\form_test\Form;
4
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Provides a base class for tableselect forms.
10  */
11 abstract class FormTestTableSelectFormBase extends FormBase {
12
13   /**
14    * Build a form to test the tableselect element.
15    *
16    * @param array $form
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.
22    *
23    * @return array
24    *   A form with a tableselect element and a submit button.
25    */
26   public function tableselectFormBuilder($form, FormStateInterface $form_state, $element_properties) {
27     list($header, $options) = _form_test_tableselect_get_data();
28
29     $form['tableselect'] = $element_properties;
30
31     $form['tableselect'] += [
32       '#prefix' => '<div id="tableselect-wrapper">',
33       '#suffix' => '</div>',
34       '#type' => 'tableselect',
35       '#header' => $header,
36       '#options' => $options,
37       '#multiple' => FALSE,
38       '#empty' => t('Empty text.'),
39       '#ajax' => [
40         'callback' => 'form_test_tableselect_ajax_callback',
41         'wrapper' => 'tableselect-wrapper',
42       ],
43     ];
44
45     $form['submit'] = [
46       '#type' => 'submit',
47       '#value' => t('Submit'),
48     ];
49
50     return $form;
51   }
52
53 }