DrupalBin
Submit Code
About
Recent Posts
Code
Fix for Fix for Code
Fix for Code
Code
Node type whitelist
an axe coach accessories
coach purses married
Fix for de las ghd alturas
de las ghd alturas
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
›
Fix for Fix for How to complete any webform submission via Ajax
Fix for Fix for Fix for How to complete any webform submission via Ajax
View
Fix
Fixes are not saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?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; }); });
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp phps
.