You are here

public function AddLineItemForm::submitForm in Ubercart 8.4

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

uc_order/src/Form/AddLineItemForm.php, line 93

Class

AddLineItemForm
Form to add a line item to an order.

Namespace

Drupal\uc_order\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  uc_order_line_item_add($form_state
    ->getValue('order_id'), $form_state
    ->getValue('line_item_id'), $form_state
    ->getValue('title'), $form_state
    ->getValue('amount'));
  $this
    ->messenger()
    ->addMessage($this
    ->t('Line item added to order.'));
  $form_state
    ->setRedirect('entity.uc_order.edit_form', [
    'uc_order' => $form_state
      ->getValue('order_id'),
  ]);
}