/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($form_state->getValue('products') as $id => $product) { if ($product['checked']) { $this->package->products[$id] = (object) $product; } else { unset($this->package->products[$id]); } } $this->package->shipping_type = $form_state->getValue('shipping_type'); $this->package->save(); $form_state->setRedirect('uc_fulfillment.packages', ['uc_order' => $this->package->order_id]); }