You are here

public function PackageEditForm::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

shipping/uc_fulfillment/src/Form/PackageEditForm.php, line 122

Class

PackageEditForm
Rearranges the products in or out of a package.

Namespace

Drupal\uc_fulfillment\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $products = [];
  foreach ($form_state
    ->getValue('products') as $id => $product) {
    if ($product['checked']) {
      $products[$id] = (object) $product;
    }
  }
  $this->package
    ->setProducts($products);
  $this->package
    ->setShippingType($form_state
    ->getValue('shipping_type'));
  $this->package
    ->save();
  $form_state
    ->setRedirect('uc_fulfillment.packages', [
    'uc_order' => $this->package
      ->getOrderId(),
  ]);
}