In my AJAX form the user has to do a validation as he needs a code to enter the rest of the form (it has 3 pages or more). I have an handler to validate this and this same handler uses that code to do get a node:
// ON the handler validate() $code_valid= $this->sessionManager->get('code_valid'); if (empty($code_valid)) { $this->handlerProperty = $this->contentService->getContentByCodeAndCurrentNodeId($node_id, $name, $code); $this->sessionManager->set('code_valid', $this->handlerProperty); } // On repository Class public function getContentByCodeAndCurrentNodeId(int $node_id, string $name, string $code) { return $this->entityTypeManager->getStorage('node') ->loadByProperties([ 'type' => 'XXXXX', 'event' => $node_id, 'name' => $name, 'code' => $code, ]); } public function confirmForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) { //If submissions is successful, delete private store $this->sessionManager->delete('code_valid'); }
My problem is that there’s no way to $this->sessionManager->delete(‘code_valid’) if the user leaves amidst the form. So I was looking for a way to persist the validation result, without resorting to sessionManager/privatestoremanager.
If you want more context the webform is setup to be used on a specific content type (A). It’s used to create/update/delete another content type (B). It’s a one to many relationship between them so this form will create multiple B dynamically, depending on the form content submitted – it can create up to 5 of B. The first step is a validation/auth to be able to use the "real" form (next steps after first).
Thanks in advance!