You are here

public function OrderUpdateForm::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_order/src/Form/OrderUpdateForm.php, line 55

Class

OrderUpdateForm
Updates an order's status and optionally adds comments.

Namespace

Drupal\uc_order\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $order = NULL) {
  $form['order_comment_field'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Add an order comment'),
  ];
  $form['order_comment_field']['order_comment'] = [
    '#type' => 'textarea',
    '#description' => $this
      ->t('Order comments are used primarily to communicate with the customer.'),
  ];
  $form['admin_comment_field'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Add an admin comment'),
  ];
  $form['admin_comment_field']['admin_comment'] = [
    '#type' => 'textarea',
    '#description' => $this
      ->t('Admin comments are only seen by store administrators.'),
  ];
  $form['current_status'] = [
    '#type' => 'value',
    '#value' => $order
      ->getStatusId(),
  ];
  $form['order_id'] = [
    '#type' => 'value',
    '#value' => $order
      ->id(),
  ];
  $form['controls'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'uc-inline-form',
      ],
    ],
    '#weight' => 10,
  ];
  $form['controls']['status'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Order status'),
    '#default_value' => $order
      ->getStatusId(),
    '#options' => OrderStatus::getOptionsList(),
  ];
  $form['controls']['notify'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Send e-mail notification on update.'),
  ];
  $form['controls']['actions'] = [
    '#type' => 'actions',
  ];
  $form['controls']['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Update'),
    '#button_type' => 'primary',
  ];
  return $form;
}