public static function PaymentLineItemsInput::ajaxDeleteSubmit in Payment 8.2
Implements form AJAX callback.
File
- src/
Element/ PaymentLineItemsInput.php, line 305
Class
- PaymentLineItemsInput
- Provides a payment line items configuration element.
Namespace
Drupal\payment\ElementCode
public static function ajaxDeleteSubmit(array &$form, FormStateInterface $form_state) {
$triggering_element = $form_state
->getTriggeringElement();
$root_element_parents = array_slice($triggering_element['#array_parents'], 0, -3);
$root_element = NestedArray::getValue($form, $root_element_parents);
$parents = $triggering_element['#array_parents'];
$line_item_name = $parents[count($parents) - 2];
$response = new AjaxResponse();
$response
->addCommand(new RemoveCommand('#' . $root_element['#id'] . ' .payment-line-item-name-' . $line_item_name));
return $response;
}