Custom Form Processor in Magento Commerce

Recently I had to create a custom lead collection form for a Magento Commerce site I was working on. Surprisingly, an explanation on how to do this wasn’t so easily found so I had to hit the IRC channel in hopes of finding someone who might have some answers. After a couple attempts, friendly community user Vortex was able to provide a solution using the following method:

What we basically end up doing is creating a custom template, and then put our form processing code in that .phtml file. It’s not the ideal method, but I haven’t found any better alternatives yet. Here are the steps:

  1. Open up  app\code\core\mage\cms\etc\config.xml, and add a template for your form processor, it should look something like this:
    <interest_form>
    <label>lead capture form</label>
    <template>page/leadcapture.phtml</template>
    </interest_form>
  2. Now switch to the home\app\design\frontend\default\theme_name\template\page folder and create your leadcapture.phtml file (or whatever you called it in the above step).
  3. Here I copied the contents of the existing 2-column template that I then just modified it as required, but you could write this part from scratch if you wanted.
  4. Once saved, I went into the Magento admin under CMS and set the Lead Capture page to use the lead capture form template.

Again, special thanks to Vortex for these instructions. If you see him in the IRC chat, don’t forget to thank him.

It’s a bit of a hack, but it works. If you know of a better way, please share in the comments, thanks!