<?php # Place the following code in your webform under the
# Advanced Webform Settings Field group inside of
# Additional Processing...
global $submission;
if(!isset($submission) || !is_array($submission)){
$err_str = $submission.PHP_EOL;
$submission = array();
}
$enabled = TRUE;
$preview = FALSE;
$args = array('submission' => $submission, 'enabled' => true, 'preview' => false);
$temp = drupal_execute($form_state['values']['form_id'],$_POST,$args);
?>
The jquery below will work for sure, however there may be a better way to get this done...
$("form#SOMEID").each(function(i, domForm){
var $submit = $(domForm);
$submit.submit(function(){return false;});
var $button = $(domForm).children('input[type="image"]'); /* This is my custom button */
var $entry = $(domForm).find('[type="text"]'); /* grab all the text fields you may to get others */
var $drupal = $(domForm).find(':hidden'); /* you need all of these for sure */
var $action = $(domForm).attr('action'); /* need this to know where to POST */
var $container = $(domForm); /* for sending feedback because you're a jerk if you don't */
/* read up on http POST if you dont get this part */
var $boundary = '-----------------------------1626259126772'; /* note that this line has two more -- then the ajaxSetup line */
var $content_lead = '\nContent-Disposition: form-data;'
/* we don't want to actually submit the form... */
$button.unbind("click");
$(domForm).unbind("submit");
$button.click(function(){
var $entered = '';
$entry.each(function(){
var $blah = $(this).attr('name');
var $blah2 = $(this).val();
$entered += $boundary + $content_lead + ' name="' + $blah + '"\n\n' + $blah2+'\n';
});
$drupal.each(function(){
var $blah = $(this).attr('name');
var $blah2 = $(this).val();
$entered += $boundary + $content_lead + ' name="' + $blah + '"\n\n' + $blah2+'\n';
});
$entered += $boundary + '\nContent-Disposition: form-data; name="op"\n\nSubmit\n'+$boundary +'--\n\n';
$.ajaxSetup({contentType: 'multipart/form-data; boundary=---------------------------1626259126772', cache: false});
$container.fadeOut("slow");
$.post($action, $entered , function(data){
var $temp = data; /* I had some issues with the form submitting when this is not done not sure if it is needed */
$container.html('<p>Thank you for your interest!<br /></p>');
$container.fadeIn("normal");}
, "html");
return false;
});
});