1c9628bcf30b28e5d99eafe48b7b2a38733053fb
[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 class FormTestTableSelectColspanForm extends FormTestTableSelectFormBase {
8
9   /**
10    * {@inheritdoc}
11    */
12   public function getFormId() {
13     return '_form_test_tableselect_colspan_form';
14   }
15
16   /**
17    * {@inheritdoc}
18    */
19   public function buildForm(array $form, FormStateInterface $form_state) {
20     list($header, $options) = _form_test_tableselect_get_data();
21
22     // Change the data so that the third column has colspan=2.
23     $header['three'] = ['data' => 'Three', 'colspan' => 2];
24     unset($header['four']);
25     // Set the each row so that column 3 is an array.
26     foreach ($options as $name => $row) {
27       $options[$name]['three'] = [$row['three'], $row['four']];
28       unset($options[$name]['four']);
29     }
30     // Combine cells in row 3.
31     $options['row3']['one'] = ['data' => $options['row3']['one'], 'colspan' => 2];
32     unset($options['row3']['two']);
33     $options['row3']['three'] = ['data' => $options['row3']['three'][0], 'colspan' => 2];
34     unset($options['row3']['four']);
35
36     return $this->tableselectFormBuilder($form, $form_state, ['#header' => $header, '#options' => $options]);
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function submitForm(array &$form, FormStateInterface $form_state) {
43   }
44
45 }