I have created a couple of webform submit handlers before, but my new one fires on every page submit rather than when the last page is submitted.
How do I get the webform handler to only fire after the full form is submitted?
Below is what I have at the moment, which fires on each page:
namespace Drupal\the_api\Plugin\WebformHandler;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;
/**
* Webform submission remote post handler.
*
* @WebformHandler(
* id = "membership_api_post",
* label = @Translation("New Membership to API"),
* category = @Translation("External"),
* description = @Translation("Posts a new membership through to the API."),
* cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
* results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
* submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_REQUIRED,
* )
*/
class NewMembershipWebformHandler extends WebformHandlerBase {
/**
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
* @param \Drupal\webform\WebformSubmissionInterface $webform_submission
*/
public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
parent::submitForm($form, $form_state, $webform_submission);
kint($form_state);
}
}