Hi guys!
I need to store users requests only when users email is confirmed. This behavior is realized by two forms: first of them collects user info and message and second accepts confirmation code that was sent to user email by the first form processing. After the second form is validated users message emailed to recipient.
I have resource with shippet that publish forms and two FormIt calls for each form.
[[!ShowRequestForm]] [[!FormIt ? &submitVar=`presubmit` &customValidators=`validateName` &validate=`name:required:validateName, email:email, message:minLength=^8^` ]] [[!FormIt ? &hooks=`email,redirect` &emailTo=`recipient email` &emailFrom=`recipient email` &emailSubject=`Subject` &emailTpl=`SuccessMessage` &redirectTo=`15` &submitVar=`submitcode` &customValidators=`validateAcceptCode` &validate=`usercode:required:validateAcceptCode` ]]
Snippet ShowRequestForm:
// We have submitted first request form if (isset($_POST['presubmit'])) { // There is configuring confirmation code // Send email with confirmation code to user $modx->runSnippet('SendEmail', array( 'to_addr' => $_POST['email'], 'to_name' => $_POST['name'], 'sender' => 'noreply address', 'subject' => 'Confirmation code', 'body' => $modx->getChunk('ConfirmationCodeBody', array( 'code' => $confCode, 'email' => $_POST['email'],)))); // Publish next form to confirm code echo $modx->getChunk('AcceptCodeForm', array( 'name' => $_POST['name'], 'email' => $_POST['email'], 'message' => $_POST['message'],)); } else { // We will accept only forms submits if (!isset($_POST['submitcode'])) echo $modx->getChunk('MeetRequestForm'); else // Second form has not passed validation echo $modx->getChunk('AcceptCodeForm', array( 'name' => $_POST['name'], 'email' => $_POST['email'], 'message' => $_POST['message'],)); }
In result I couldn’t stop at validation failure for the first form. When it submitted I’m always stand on second form.
When I add snippet ShowRequestForm to hook of the first form, there is no changes happens.
What I do wrong? How to stop processing when the first form is not validated?