I'm writing a custom WebformHandler and am wondering how I can prevent a submission from being saved? I've tried using the RESULTS_IGNORED and SUBMISSION_OPTIONAL in the @WebformHandler annotation, but the submissions still get saved. Is there an additional step, say in the submitForm() method?
/**
* Premium Content Webform Handler.
*
* This is a custom handler to tie into the premium content form to handle
* when the user submits the form and either re-sends them the link to the
* content, or takes them to the credit card processor to complete the
* transaction.
*
* @WebformHandler(
* id = "lazy_handler",
* label = @Translation("Lazy Handler"),
* category = @Translation("Custom"),
* description = @Translation("Only saves on Mondays."),
* cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
* results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_IGNORED,
* submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_OPTIONAL
* )
*/
class LazyWebformHandler extends WebformHandlerBase {
public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
$is_monday = FALSE;
if (!$is_monday) {
// Do I do something here to prevent the submission from being saved?
}
}
}