public function FormTestTableSelectColspanForm::buildForm in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php \Drupal\form_test\Form\FormTestTableSelectColspanForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- core/
modules/ system/ tests/ modules/ form_test/ src/ Form/ FormTestTableSelectColspanForm.php, line 24 - Contains \Drupal\form_test\Form\FormTestTableSelectColspanForm.
Class
Namespace
Drupal\form_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
list($header, $options) = _form_test_tableselect_get_data();
// Change the data so that the third column has colspan=2.
$header['three'] = array(
'data' => 'Three',
'colspan' => 2,
);
unset($header['four']);
// Set the each row so that column 3 is an array.
foreach ($options as $name => $row) {
$options[$name]['three'] = array(
$row['three'],
$row['four'],
);
unset($options[$name]['four']);
}
// Combine cells in row 3.
$options['row3']['one'] = array(
'data' => $options['row3']['one'],
'colspan' => 2,
);
unset($options['row3']['two']);
$options['row3']['three'] = array(
'data' => $options['row3']['three'][0],
'colspan' => 2,
);
unset($options['row3']['four']);
return $this
->tableselectFormBuilder($form, $form_state, array(
'#header' => $header,
'#options' => $options,
));
}