You are here

public function HubspotWebformHandler::removeSubscription in HubSpot 3.x

Ajax call back for removing subscription mapping row.

Parameters

array $form: Drupal form render array.

\Drupal\Core\Form\FormStateInterface $form_state: Drupal form state for ajax callback.

Return value

mixed Drupal ajax response.

File

src/Plugin/WebformHandler/HubspotWebformHandler.php, line 570

Class

HubspotWebformHandler
Webform submission remote post handler.

Namespace

Drupal\hubspot\Plugin\WebformHandler

Code

public function removeSubscription(array &$form, FormStateInterface $form_state) {
  $trigger = $form_state
    ->getTriggeringElement();
  $element_path = $trigger['#parents'];
  array_pop($element_path);
  $selector = '#edit-' . implode('-', $element_path);
  $response = new AjaxResponse();
  $response
    ->addCommand(new RemoveCommand($selector));
  return $response;
}