Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestTableSelectColspanForm.php
1 <?php
2
3 namespace Drupal\form_test\Form;
4
5 use Drupal\Core\Form\FormStateInterface;
6
7 /**
8  * Builds a form to test table selects with different column spans.
9  *
10  * @internal
11  */
12 class FormTestTableSelectColspanForm extends FormTestTableSelectFormBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function getFormId() {
18     return '_form_test_tableselect_colspan_form';
19   }
20
21   /**
22    * {@inheritdoc}
23    */
24   public function buildForm(array $form, FormStateInterface $form_state) {
25     list($header, $options) = _form_test_tableselect_get_data();
26
27     // Change the data so that the third column has colspan=2.
28     $header['three'] = ['data' => 'Three', 'colspan' => 2];
29     unset($header['four']);
30     // Set the each row so that column 3 is an array.
31     foreach ($options as $name => $row) {
32       $options[$name]['three'] = [$row['three'], $row['four']];
33       unset($options[$name]['four']);
34     }
35     // Combine cells in row 3.
36     $options['row3']['one'] = ['data' => $options['row3']['one'], 'colspan' => 2];
37     unset($options['row3']['two']);
38     $options['row3']['three'] = ['data' => $options['row3']['three'][0], 'colspan' => 2];
39     unset($options['row3']['four']);
40
41     return $this->tableselectFormBuilder($form, $form_state, ['#header' => $header, '#options' => $options]);
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function submitForm(array &$form, FormStateInterface $form_state) {
48   }
49
50 }