Please note that the forum isn't realy used anymore.

If you have questions, want support or just simply want to talk to us you can find us on slack.

 

Confirmation msg after submit form

Hey

So I ve constructed a form, but not with the formbuilder. The form is being send, attachment is send with it etc. However i would like to show a msg informing the sender that the msg was successfully sent.

After the sending of the mail i redirect to ?mail=sent.

How can i do this?

Code for the form is:

$message = \Common\Mailer\Message::newInstance($item['subject']) ->setFrom(array($item['email'] => $item['fullName'])) ->setto(array($to['email'] => $to['name'])) ->setReplyTo(array($item['email'] => $item['fullName'])) ->attach( \SwiftAttachment::fromPath($FILES['file']['tmpname'])->setFilename( $item['voornaam'].' '. $item['naam'].'.'.$fileExt) ) ->parseHtml( FRONTENDMODULES_PATH . '/Jobs/Layout/Templates/Mails/Apply.tpl', $item, true ) ; $this->get('mailer')->send($message);

// get URL f $permaLink = $this->record['full_url']; $redirectLink = $permaLink; $redirectLink .= '?mail=sent';

// redirect $this->redirect($redirectLink);

Hmm try to do something like what the Formbuilder module does. Use this in your template:

{option:successMessage}
    <div class="message success">{$successMessage}</div>
{/option:successMessage}

and check for the url parameter when you start executing the php code of that page. When you redirect the page to ?mail=sent, the php code gets re-executed. So inside the execute() function goes something like this:

// success message
if ($this->URL->hasParameter('identifier') && $this->URL->getParameter('identifier') == $this->item['identifier']) {
    $this->tpl->assign('successMessage', $this->item['success_message']);
} else {
    // create/handle form otherwise
    $this->loadForm();
    $this->validateForm();
    $this->parse();
}

but probably change "identifier" to mail, and check if parameter 'mail' == 'sent'

Comment

The forum is deprecated in favor of our Slack channel, which provides real-time support for your issues.

Join us on Slack here: https://fork-cms.herokuapp.com/