Contact form with selectable recipients

Permalink
Not sure whether this fits in the "editing" or "building" forum so apologies if I've posted in the wrong place. I'll try to be brief although as a total newbie I may get my terminology wrong.
I'm building a site for my local U3A and want the contact form to contain a dropdown to select which committee member or group leader the message is for: I can do that by adding a box to the standard concrete5 contact form or by using an external script (such as that from addressmunger.com). In the first case I don't know where to find (or how to edit) the sendmail script that I need to edit to allow different recipients according to the selection in the form, and in the second I don't know how to incorporate the script into concrete5. I've tried creating a separate contact page outside concrete5 with the necessary form and php, and using an iframe within concrete5 to display the form. This works, but is not very elegant.
I would like a neater solution but it needs to be within my very limited capabilities, and I would welcome input from anyone with ideas on the easiest way to accomplish this.
Thanks in advance.

 
hutman replied on at Permalink Reply
hutman
Are you using 5.6 or 5.7? If 5.6 I'd suggest the Advanced Forms add-on, if 5.7 probably make an external form and custom code it.
turkishjim replied on at Permalink Reply
Many thanks, hutman, for taking the time to reply.

I'm running cloneamental on 5.7.5.7.
You suggest custom coding an external form, which I think I can do, and I presume I would then insert the php/html code into an html block on the page in concrete5. My problem then would be working out where to put the php which actually does the work of sending the e-mail to the selected recipient. I'm really new to PHP, concrete5 and CMS in general, and find the concrete5 file structure a bit confusing. Are you able to point me towards any resources which would help?

Thanks in advance.
hutman replied on at Permalink Reply 1 Attachment
hutman
Here is an example, this would go into your /application/blocks/external_form directory so the structure would be /application/blocks/external_form/form/example_form.php

Then to add it to your site there is a block called External Form and "Example Form" will be an option in the dropdown for that block.

Let me know if you have questions about this.
turkishjim replied on at Permalink Reply
Appreciate that very much, hutman. I've loaded the form and tweaked it a little (successfully, to my surprise!) and it shows up nicely in concrete5. When I get a bit more time I'll try to tweak the controller file as well so that everything works as it should. If I have any problems I'll take you up on your generous offer of further assistance, if I may.
I'd also like to add some form of robot-beating trick, either a CAPTCHA or a simple Q and A. I'm sure I can find the code for the latter online and build it in to the form, but is there a simple way to add a CAPTCHA to this custom form in concrete5?
hutman replied on at Permalink Reply
hutman
You should be able to do this for display

<div class="form-group">
    <label class="control-label"><?php $captcha->label(); ?></label>
    <?php $captcha->display(); ?>
    <?php $captcha->showInput(); ?>
</div>


And this for validation

$captcha = Core::make("captcha");
if (!$captcha->check()) {
    echo t('Captcha is invalid');
}
Gondwana replied on at Permalink Reply
Gondwana
Another approach would be to adapt this:
https://www.concrete5.org/marketplace/addons/contact-form-no-links1...

If you look in the add-on's support page, you'll see that another user has worked out how to add a selection box to the form. You'd need to use its contents for the email address, and probably strip out other stuff you don't want.
turkishjim replied on at Permalink Reply
Thank you for your input, Gondwana: I'll have a look at that when I get a moment.
Hutman, thank you as well for the captcha details. I've put those on the back burner for the moment as my target audience is, like me, over 60 so may well find captchas difficult and off-putting. On reflection I may go for a honeypot instead.
First of all however I need to get the form working and actually sending e-mails! I've put the folder "form" in my web structure where you advised, and simply changed the 2 recipient e-mail addresses on the php in the "controller" folder to ones in my control. In the absence of any idea where to place the "controller" folder, I've left it as a sub-folder of "form". I suspect this is wrong, however, or I need to alter some other setting(s) as when I complete the form on my web page and click "submit" I get "404 Error Page not found". Sorry to be a pain but your help in identifying my error would be appreciated (yet again!)
hutman replied on at Permalink Reply
hutman
I think you have the files correct, it should be

/application/blocks/external_form/form/example_form.php
/application/blocks/external_form/form/controller/example_form.php

I've seen the 404 issue before but it usually has to do with Pretty URLs, I can't remember offhand if it's when they are on or off. But playing with that will likely fix your issue
turkishjim replied on at Permalink Reply
Thanks for all your help, hutman. I've been away for a couple of days so apologies for not responding sooner.
I tried turning off pretty urls but that did not work, I'm afraid. I've gone back to the iframe solution which actually looks quite good now that the css is right, so I think that will do for the time being.