External form email sending

Permalink
Hi,

I've been looking around the forums and I'm getting very confused about the whole sending form data to an email.

I'm trying to create a form in which people put details in and then all the data is sent to me.

I've created an external form but now I don't know what to do now? is there any code out there in which I can use or anything like that??

Thanks

Gary

 
pvernaglia replied on at Permalink Reply
pvernaglia
You need to make a controller for your external form in blocks/external_form/forms/controllers with the same name as your external form and put a function there to send mail. Something like this:

public function action_contact_form() {      
      $val = Loader::helper('validation/form');
      $mh = Loader::helper('mail');
      // Validate
                $val->setData($this->post());
                $val->addRequiredEmail('email', 'Please Enter a Valid Email Address.');
      // You get form data like this
      $fullName = $this->post('full_name');
      $company = $this->post('company');   
      $email = $this->post('email');      
      // If no errors
      if ($val->test()) {
       // Send Email
                $mh->setSubject('Website Contact Form');
            $mh->setBody("Web Site Contact Form\n".


if you look at the core form block you can see how it is sending mail, you can also make a mail template file to format the message
blueflightmedia replied on at Permalink Reply
i dont want to sound like a noob again how do i make a email template as well? not very good with php sorry!
blueflightmedia replied on at Permalink Reply
this is all very confusing! wish they would make it alot easier to do this!
TheRealSean replied on at Permalink Reply
TheRealSean
Can you not just use the internal form instead of the external form?

There is an option to send an email to you when a form is submitted?
I thought the content was displayed in that email? it's only plain text but should be enough?
blueflightmedia replied on at Permalink Reply
no i cant because the form I have is a bit more complicated then the internal form can create.
also don't want the email to go to me. I need it to go to my clients email.
TheRealSean replied on at Permalink Reply
TheRealSean
You can change the location that the email is sent to instead of using yours.

There are a couple of advanced forms in the market place, including a community one that is being worked on,
http://www.concrete5.org/community/forums/block_requests/new-commun...

The market place link
http://www.concrete5.org/marketplace/addons/-/view/?submit_search=1...

What sort of fields do you need that the default one does not offer? we may be able to add them to the community one if not to difficult?
blueflightmedia replied on at Permalink Reply
I need a field in which you select a date from a calender or something like that to let the user choose a date from something?

I have managed to create a external form which allows that but just now I don't know what to do be able to send the data to an email!

Thank you for your help.
TheRealSean replied on at Permalink Reply 1 Attachment
TheRealSean
I have attached a version of the community form I have edited, to include a date block

Its just a text field with a datePicker

This was a private edit I have made so it may break? but give it a go. Once added choose, custom template and Div_wrapper instead of its default display
blueflightmedia replied on at Permalink Reply
Thanks alot :)

Added the community form where though?

Sorry still getting really confused with the custom blocks and templates.

Thanks Gary
TheRealSean replied on at Permalink Best Answer Reply
TheRealSean
You will need to unzip the folder into your site root

root>blocks>community_form

upload this,
Log into your Site,
go to Dashboard,
"Add Functionality"
on the right you should see Blocks available to install
Install the block

Once installed
Visit page
Add Block
Scroll to the bottom of the page
Add community form
Create your form, by adding the required fields(here's the bit I am hoping just works)
In Options add the email of the person your are sending too, yourself if you want to test,
Once done select Add
Exit Edit Mode, then test the form
blueflightmedia replied on at Permalink Reply
Awesome thank you very much!

Just texting it now so will let you know if works or not!

Thank you again
blueflightmedia replied on at Permalink Reply
It all works fantastic and looks great! thank you very much :)
TheRealSean replied on at Permalink Reply
TheRealSean
No problem :) glad it all works
blueflightmedia replied on at Permalink Reply
Just one quick question is there a way that you can make the questions like side by side instead of under eachother?
TheRealSean replied on at Permalink Reply
TheRealSean
you would need to adjust the css, in the template folder, there is a file view.css that you could edit,

For a particular question, just check on the id.

Its designed like that as that's how we have them on our sites.

But you could use something like

#question10 {width:50px; float:left;}


Each question and answer may be in a row?, so you may need to add a class in the view.php,

foreach array as var
if question id == value
add class

but thats a little more complex as it involves tweaking with the code.
blueflightmedia replied on at Permalink Reply
ok thanks again :) i'l have a play around with the css and see what happens!
TheRealSean replied on at Permalink Reply
TheRealSean
Just also noticed these are not visible in the dashboard under forms, you need to add a file called

forms.php

into
root>controllers\dashboard\reports\ (you may need to create these folders)

then paste in the following, after that you should be able to view the submitted forms on the dashboard under forms,
caution this will over ride the default forms file.
<?php 
defined('C5_EXECUTE') or die("Access Denied.");
Loader::block('community_form');
class DashboardReportsFormsController extends Controller {
   private $pageSize=3; 
   public function view(){   
      if($_REQUEST['all']){
         $this->pageSize=100000; 
         $_REQUEST['page']=1;
      }
      $this->loadSurveyResponses();
   }
   public function excel(){ 
      $dateHelper = Loader::helper('date');
      $this->pageSize=0;