brandy Posted September 19 Share Posted September 19 Hi! I am using Formbuilder on a website. The form is for contacting, if you are interested in a real estate. With the following code I read out, on which site you are sending the contact form: <?php $form = $forms->render('kontakt', [ 'form_page' => $page->parent->title . " " . $page->title ]); ?> So you receive a mail with the parent-page and page-title as subject, which works perfectly. Is it now possible to extend this and send the contact-form to different mailadresses, depending on the page-parent? I do have a field in the parent, which is linked to the right contact-information. Thanks a lot! Link to comment Share on other sites More sharing options...
elabx Posted September 19 Share Posted September 19 I think you'd have to customize the autoresponder template from FormBuilder. Check the instructions in site/modules/FormBuilder/email-autoresponder.php, in the comments at the top of the file. Link to comment Share on other sites More sharing options...
brandy Posted September 20 Author Share Posted September 20 Thanks a lot! But in the file there is no information about the sender. Where does the form get its sending information? Thanks a lot! Link to comment Share on other sites More sharing options...
elabx Posted Wednesday at 03:12 PM Share Posted Wednesday at 03:12 PM You know what, I misread your issue. What could probable work is placing a hook in emailFormReady https://processwire.com/store/form-builder/hooks/#where-to-place-hooks wire()->addHookBefore("FormBuilderProcessor::emailFormReady",function($e){ /** @var InputfieldForm **/ $form = $e->arguments(0); /** @var FormBuilderEmail **/ $email = $e->arguments(1); if($form->name !== "the_form_in_question") return; $page_id = $form->getChildByName('form_page_id'); if($page_id){ $contact_email = wire('pages')->get($page_id)->contact_email; $email->to = $contact_email; } }) form_page_id would be a hidden field in the form where you save the page_id, not sure if there is a nicer way to do this! That is, without this hidden field to pass on the id info. Link to comment Share on other sites More sharing options...
brandy Posted 19 hours ago Author Share Posted 19 hours ago Thanks a lot! I do have a construction, like this, for the emailSubject: <?php $processor = $event->object; $processor->emailSubject = "Page title is: $page->title"; echo $form; ?> Is it possible to make it very simple like $processor->emailReceipient = Only a quick thought! 1 Link to comment Share on other sites More sharing options...
elabx Posted 19 hours ago Share Posted 19 hours ago Oh I see! I guess that could work! Did you try?? I hadn't noticed that property was set on the Processor object. Link to comment Share on other sites More sharing options...
brandy Posted 17 hours ago Author Share Posted 17 hours ago Yeah, i forgot it too. I added following: $processor->emailTo = "{$page->parent->projekt_bautraeger->bautraeger_mail}"; As the e-mail is a pageReference-field in the parent, I have to build it like that, but it doesn´t work. The following shows me the emailadress: echo "{$page->parent->projekt_bautraeger->bautraeger_mail}"; Do you think there is a problem, as the form has recipients in the backend? All in all emailTo seems good to me: https://processwire.com/api/ref/form-builder-processor/ Link to comment Share on other sites More sharing options...
brandy Posted 6 hours ago Author Share Posted 6 hours ago FYI: I disabled the recipients in the backend, but it doesn´t work either! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now