External form email sending


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??



View Replies:
glockops replied on at Permalink Reply
Sorry for a year delay on an answer, but hopefully this will help others that stumble in from Google (like I did)..

External Forms are made up of two or more files.
The form HTML
The form's controller file
Separate form JavaScript/etc (optional files)

Let's say we're going to create a form that allows a customer to send you a number of widgets.

We create a form in blocks/external_form/forms/my_widget_form.php that contains all the HTML markup to create the form. In the markup we have a form field quantity and a form field email.

Now we need to create a form controller to handle all the computations associated with this form - it is created in blocks/external_forms/forms/controllers/my_widget_form.php

There should be an example of a controller for the "Test Form" in concrete/blocks/external_forms/forms/controllers/test_form.php

In the controller, you'll create a function that matches your form's action. So if your action is "order_widgets" your controller will have a function called action_order_widgets.

defined('C5_EXECUTE') or die("Access Denied.");
class MyWidgetFormExternalFormBlockController extends BlockController {
   public function action_order_widgets() {
      $val = Loader::helper('validation/form');
      // Validate your data
         // ...
      if(!$val->test()) {
         // validation failed, display error
      } else {
         // Format mail and send
         $mh = Loader::helper('mail');
         $mh->to('[email protected]');
         $mh->from($this->post('email')); // Use submitter's email

In this controller function, you can add validation, handlers, database connections, etc.

You can also create an "on_page_view()" function to load form CSS and JS files. Here's an example:
public function on_page_view() {
      // Include external files
      $html = Loader::helper('html/v2');

For your particular problem (emailing) you'll need to make use of the mail helper (http://www.concrete5.org/documentation/developers/helpers/mail) you'll probably also want to look at validation (http://www.concrete5.org/documentation/developers/forms/basic-validation) and error handling (http://www.concrete5.org/documentation/developers/system/error-handling/) and finally, you may find front-end JavaScript validation (http://unwrongest.com/projects/valid8/) useful as well.
gd42 replied on at Permalink Reply
Is it possible to somehow include the actual page title in the e-mail?

So like I have the same form on multiple different pages and I want to know on which page was the form filled?
hardingsmith replied on at Permalink Reply
You could add a hidden field to your external form template which takes the collection name (or whatever collection attribute grabs you) as it's value.
felixb101 replied on at Permalink Reply
Custom form are not that hard. However they require a few basic skills. We can help (Canada.) to do that.http://www.studiolettrage.ca