function CartForm::submitRemoveSelected

Form submit callback to remove the selected items.

File

src/Form/CartForm.php, line 117

Class

CartForm
Source overview form.

Namespace

Drupal\tmgmt\Form

Code

function submitRemoveSelected(array $form, FormStateInterface $form_state) {
  $job_item_ids = array_filter($form_state
    ->getValue('items'));
  tmgmt_cart_get()
    ->removeJobItems($job_item_ids);
  \Drupal::entityTypeManager()
    ->getStorage('tmgmt_job_item')
    ->delete(JobItem::loadMultiple($job_item_ids));
  $this
    ->messenger()
    ->addStatus(t('Job items were removed from the cart.'));
}