I am stepping over my own feet here. I have created an ajax form submission that stores to a db. Now I need to get an email notification sent to the site admin.
Here is the code producing an ajax error each time I submit the form:
<?php
/**
* FORM API
*/
/*
* Implements hook_menu()
*/
function contact_menu() {
$items['contact'] = array(
'title' => 'View the sample form',
'page callback' => 'drupal_get_form',
'page arguments' => array('contact_nameform'),
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM
);
return $items;
}
/*
* Implements hook_theme
*/
function contact_theme() {
return array(
'contact_nameform' => array(
'render element' => 'form',
'template' => 'contact_nameform',
),
);
}
/*
* Assign the elements of the form to variables
*/
function template_preprocess_contact_nameform(&$variables) {
$variables['contact_nameform'] = array();
$hidden = array();
//Provides variables named after form keys
foreach (element_children($variables['form']) as $key) {
$type = $variables['form'][$key]['#type'];
if ($type == 'hidden' || $type == 'token') {
$hidden[] = drupal_render($variables['form'][$key]);
}
else {
$variables['contact_nameform'][$key] = drupal_render($variables['form'][$key]);
}
}
// Hidden form elements have no value to the theme