How to get the form block to send email to form submitter
First, I copied the core form block folder (root/concrete/blocks/form) to the root blocks folder (root/blocks/form).
Next i edited the controller.php file in root/blocks/form. I added a block of code around line 340 above the code that sends an email to the address entered in the block itself. Here's the code:
$mh = Loader::helper('mail'); $mh->to( $questionAnswerPairs['answer'] ); $mh->from( $formFormEmailAddress ); $mh->addParameter('formName', $this->surveyName); $mh->addParameter('questionSetId', $this->questionSetId); $mh->addParameter('questionAnswerPairs', $questionAnswerPairs); $mh->load('block_form_submission_user'); $mh->setSubject(t('%s Form Submission', $this->surveyName)); //echo $mh->body.'<br>'; $mh->sendMail();
$mh->to( $questionAnswerPairs['answer'] );
I wanted to format the email the submitter receives differently from the one I receive. The form block uses a file called block_form_submission.php (found in the core/mail folder) to format form submission emails. I copied this file to the root/mail folder and changed it to my liking. Next I copied it to another file and named it block_form_submission_user.php, this is the file used to format the email that the form submitter receives. This line from the code above tells the block to use this alternate file:
That's pretty much it. I'm sure there are more elegant ways to accomplish this and yes, i could have just purchased a block that would do all this and more. BUT, I typically learn by doing and this has taught me alot about C5. Also I'm cheap. Sue me. As I learn more about php, i will be able to a better job. In the mean time, I'm just glad it works.
Hope this helps somebody out there with the same questions I had.
I get many requests for this feature!
I'm not exactly sure what the code here does, but it looks like it extends some base classes. Where can I find these base class files? Any help on finding the equivalent controller.php file that brothersjef edited will be appreciated. Thank you.