Hi,
yes, there are a couple of things to add. In order to not make this is a super long thread, I attached an example form that you can import in BF => Configuration => Package Installer (first unzip the file below).
This example let's a user decide if he wants to receive a PDF or not and you should be able to adjust this for your needs.
The "magic" is going on in the form => advanced => more options => submit pieces => end submit.
I left a few comments for you to see what needs to be edited. But in principle it checks for the receipient's email address given with the submission, creates a new PDF that is goin to be attached and else than that, prints the remaining fields into the email body:
$this->execPieceByName('ff_InitLib');
global $ff_processor;
$from = 'noreply@crosstec.org'; //change to wanted email
$fromname = 'Crosstec'; //change to wanted from name
$subject = 'Your PDF'; // Change to your preferred Email subject
$receipient = ''; // will be populated below
$attachment = [];
$body = '';
foreach ($this->maildata as $data) {
// for the field "pdfornot", create the PDF and attach
if($data[_FF_DATA_NAME] == 'pdfornot' && $data[_FF_DATA_VALUE] == '1'){
$attachment[] = $ff_processor->exppdf();
}
// determine the receipient for the "email" field
else if($data[_FF_DATA_NAME] == 'email'){
$receipient = $data[_FF_DATA_VALUE];
}
// else print the remaining field values in the email body
else
{
$body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
}
}
$this->sendMail($from, $fromname, $receipient, $subject, $body, $attachment);
Please let me know if this helps!
Regards,
Markus