FormTestTableSelectColspanForm.php in Drupal 10
File
core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php
View source
<?php
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormStateInterface;
class FormTestTableSelectColspanForm extends FormTestTableSelectFormBase {
public function getFormId() {
return '_form_test_tableselect_colspan_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
[
$header,
$options,
] = _form_test_tableselect_get_data();
$header['three'] = [
'data' => 'Three',
'colspan' => 2,
];
unset($header['four']);
foreach ($options as $name => $row) {
$options[$name]['three'] = [
$row['three'],
$row['four'],
];
unset($options[$name]['four']);
}
$options['row3']['one'] = [
'data' => $options['row3']['one'],
'colspan' => 2,
];
unset($options['row3']['two']);
$options['row3']['three'] = [
'data' => $options['row3']['three'][0],
'colspan' => 2,
];
unset($options['row3']['four']);
return $this
->tableselectFormBuilder($form, $form_state, [
'#header' => $header,
'#options' => $options,
]);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}