public function OrderReportGenerateForm::buildForm in Commerce Reporting 8
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
- src/
Form/ OrderReportGenerateForm.php, line 59
Class
- OrderReportGenerateForm
- Profides a form for bulk generating order reports.
Namespace
Drupal\commerce_reports\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$plugin_types = $this->reportTypeManager
->getDefinitions();
$plugin_options = [];
foreach ($plugin_types as $plugin_id => $plugin_definition) {
$plugin_options[$plugin_id] = $plugin_definition['label'];
}
asort($plugin_options);
$form['plugin_id'] = [
'#type' => 'select',
'#title' => $this
->t('Report types'),
'#description' => $this
->t('Select all report types or a single report type to be generated.'),
'#empty_option' => $this
->t('All Reports'),
'#empty_value' => '',
'#options' => $plugin_options,
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Generate'),
'#button_type' => 'primary',
];
return $form;
}