Closed (fixed)
Project:
Webform
Version:
6.x-2.7
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Sep 2009 at 09:19 UTC
Updated:
27 Aug 2011 at 22:57 UTC
I will like to display the form result(submit the form to itself, wrapped in a hidden div) within the block itself(as well as the same page), instead of it redirecting to something like node/%webform/done?sid=?.
I tried overriding the hook_form_alter or hook_form_FORM_ID_alter, but it seems these functions cannot be overriden in the theme level, unless it is implemented by another module.
In my implementation anyway, I tried using the AHAH form type, so that the path attribute calls the drupal_get_destination() function, and the wrapper attribute updates a div.
function custommodule_webform_client_form_alter(&$form, &$form_state) {
if($form_id == 'webform_client_form') {
$form['wrapper'] = array(
'#prefix' => '<div id=feedback-result',
'#suffux' => '</div>',
);
$form['wrapper'] += _webform_confirmation($node);
$form['#submit'] = array(
'ahah' => array(
'path' => drupal_get_destination(),
'wrapper' => 'feedback-result',
'method' => 'replace',
'effect' => 'fade',
'event' => 'click'
),
);
}
}
Comments
Comment #1
quicksketchI'm not sure I'd recommend this approach, and I certainly don't think it's possible with the current implementation of Webform. It'd probably require a good amount of reworking to get operating properly, especially considering page breaks, file uploads, and the confirmation page.
In the short term, I'd recommend that you just use an iFrame in your block, which will give the appearance of not leaving the page and showing the confirmation in the same place as the form.
Comment #2
quicksketchComment #3
nlambert commentedHi!
The following information doesn't necessarily relate to the Webform module, but it does relate to this issue and proposed solution.
I managed this with the PURL (Persistent URL) module, as I needed a different page template for the iframe.
Here are the different steps
1. Install CTOOLS and PURL
2. create a module and implement hook_purl_provider :
3. go to admin/settings/purl and add a "type"
=> in my case I added "Query String"
4. in admin/settings/purl configure your "settings"
=> I added "location" to "key"
5. create a node and insert your iframe
6. in your module add hook_preprocess_page
Hope this helps someone