You are here

public function CustomProductReport::buildForm in Ubercart 8.4

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

uc_report/src/Form/CustomProductReport.php, line 45

Class

CustomProductReport
Generates customized product reports.

Namespace

Drupal\uc_report\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $values) {
  $form['search'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Customize product report parameters'),
    '#description' => $this
      ->t('Adjust these values and update the report to build your custom product report. Once submitted, the report may be bookmarked for easy reference in the future.'),
  ];
  $form['search']['start_date'] = [
    '#type' => 'date',
    '#title' => $this
      ->t('Start date'),
    '#default_value' => [
      'month' => $this->dateFormatter
        ->format($values['start_date'], 'custom', 'n'),
      'day' => $this->dateFormatter
        ->format($values['start_date'], 'custom', 'j'),
      'year' => $this->dateFormatter
        ->format($values['start_date'], 'custom', 'Y'),
    ],
  ];
  $form['search']['end_date'] = [
    '#type' => 'date',
    '#title' => $this
      ->t('End date'),
    '#default_value' => [
      'month' => $this->dateFormatter
        ->format($values['end_date'], 'custom', 'n'),
      'day' => $this->dateFormatter
        ->format($values['end_date'], 'custom', 'j'),
      'year' => $this->dateFormatter
        ->format($values['end_date'], 'custom', 'Y'),
    ],
  ];
  $form['search']['status'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Order statuses'),
    '#description' => $this
      ->t('Only orders with selected statuses will be included in the report.'),
    '#options' => OrderStatus::getOptionsList(),
    '#default_value' => $values['status'],
  ];
  $form['search']['actions'] = [
    '#type' => 'actions',
  ];
  $form['search']['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Update report'),
  ];
  return $form;
}