Sorry, I hadn't tried the form submission when I posted that code. It does send the email, but it needs something to redirect it back to the original page, or just close the colorbox and post a "email sent" message. I'm not sure how to do that.
In addition, I made a small modification to #7 which uses drupal messages rather than duplicating the thank you message. It has the benefit of automatic styling, as well as showing any send errors that occur even though the form validates.
/**
* Javascript submit handler for the forward module
*/
function custom_forward_js_submit($form, &$form_state) {
// Resize the modal box.
$javascript = '
<script type="text/javascript">
(function ($) {
$(document).ready(function() {
setTimeout(function() {
var h = $("#cboxNode").height() + 100;
var w = $("#forwardWrapper").width();
$.fn.colorbox.resize({width:w, height:h});
}, 0);
});
})(jQuery);
</script>';
// Lets display our confirmation message.
if (!form_get_errors()) {
// Return our markup.
$markup = array(
'#type' => 'markup',
'#markup' => theme('status_messages') . $javascript,
);
return $markup;
}
else {
// We just pass through our $form
return $form;
}
}
Comments
Comment #1
iLLin commentedWhat type of integration?
Comment #2
jglynn commentedGetting forward module to open it's forward page dialogue in colorbox would be ideal
Comment #3
jglynn commentedA simple hack for the forward module (7.x-1.3) is change lines 1538 +1539 to
Comment #4
chriz001 commentedYour simple hack works with the latest dev version but not 2.2... (I think)
But how about after submitting the form? I was sent to a page of Ajax data.
Comment #5
iLLin commentedUse 2.3, 2.2 was built wrong somehow.
As far as making it ajax, you can do a form alter to do that.
Comment #6
jglynn commentedSorry, I hadn't tried the form submission when I posted that code. It does send the email, but it needs something to redirect it back to the original page, or just close the colorbox and post a "email sent" message. I'm not sure how to do that.
Comment #7
chriz001 commentedIve managed to get it working using 2.3 thanks to iLLin's suggestion. :)
I pretty much copied some of the webform specific code and adapted it into a custom module.
i didn't end up changing the forward module, i just used a custom link.
anyway, here is the code:
Comment #8
iLLin commentedGood Job! Marking this as fixed.
Comment #9
jglynn commentedNice work, thanks for posting your code.
Comment #10
chriz001 commentedyour welcome :)
Comment #12
carn1x commentedJust in case anybody wants something a little more lightweight and doesn't want to hack the forward.module, here's the code that works for me:
Comment #13
carn1x commentedIn addition, I made a small modification to #7 which uses drupal messages rather than duplicating the thank you message. It has the benefit of automatic styling, as well as showing any send errors that occur even though the form validates.