webforms in panels

Events happening in the community are now at Drupal community events on www.drupal.org.
rgucci's picture

Has anyone else tried to use webforms in a panel? Generally everything is working ok, except for some usability issues.

  1. if there is an error in the webform validation (missing mandatory fields, invalid email format, etc.), the page redirects to the webform node page with the error messages, and not to the original panel page (specifying internal:panel-page-url seems to work only for successful submissions)
  2. I specify internal:panel-page-url and after a successful submission, redirects to the panel page, but there is no "success message" displayed, so the user has no clue whether or not the submission was successful.

anyone has any thoughts or alternative implementations?

Comments

sounds like a bug in webform.

dalin's picture

sounds like a bug in webform. Try searching for an existing one here:

http://drupal.org/project/issues/search/webform

If not submit a new bug

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his

Temporary fix for this

fuzzter's picture

Not sure if this is still a problem for you but I just ran across the same problem and put up the following quick fix. This has only been test on drupal 6.14 and panels 2. It needs to go into a module to work and was inspired webform_block.

<?php
/**
* Implementation of hook_form_alter(&$form, $form_state, $form_id)
*
* Catch forms that live on a panel to redirect their action back to the same panel.
*/
function bluerinse_form_alter(&$form, $form_state, $form_id)
{

 
// Get the menu object for the current page. 
 
$menuItem = menu_get_item();

 
// If the callback method is the panel / pages module, do a bit of extra processing.
 
if ($menuItem[page_callback] == 'page_manager_page_execute') {

   
// Loop through the elements of the panel page to see if one them is the current form.
   
foreach ($menuItem['page_arguments'] as $item) {

     
$nid = $form['details']['nid']['#value'];

     
// Only deal with elements which are nodes...
     
if (gettype($item) == 'object' && get_class($item) == 'ctools_context') {

       
// If we've found one, update it's action to point back to the same panel page.
       
if ( $item->data->nid == $nid) {
         
form_clean_id(null, true);
         
$form['#action'] = url(drupal_get_path_alias($_GET['q']));
        }
      }
    }
  }
}
?>

Where did you paste this fix?

teamA's picture

I am having the same problem - I can't tell what file I should add this code to, where does it go?

Thanks,
Aris

Apparently this fixes it!

teamA's picture

Here's a patch - http://drupal.org/node/377420

Not so much. Still wondering about your solution.

Thanks,
Aris

Using the AJAX module

teamA's picture

seems like a good solution - everything stays on the page.

Aris

hm, running into the same

headkit's picture

hm, running into the same pitch.
don't get the idea above.
this function has to be pushed into template.php? the patch in http://drupal.org/node/377420 isn't necessary? (and not working with p3).

please, gimme a hint!

Needs to be in a module

fuzzter's picture

Hi,

The fix above was originally written as a quick and dirty fix to provide the required functionality to the client. As this was a small problem in a bigger sea of custom built functionality, I stuck this in one of the modules I was writing for the client.

Once again, this was only tested under Panels 2, so may not work with Panels 3, although I guess it doesn't hurt to try.

To get it working, you'll need to create your own basic module. It's fairly trivial and should only take about 5-10 mins.

Here's what you need to do for a module called XXXX. To create your own, just replace any instance of XXXX with whatever name you give your module. Just make sure to use a simple name with no funny characters / spaces to make your life easier.

Start by creating a directory called {path of your drupal install}/sites/all/module/XXXX.

In that directory, creating a file called XXXX.info and add the following text to it :

name = XXXX Module
description = A module to fix webforms on panels.
core = 6.x

Still in the same directroy, create a file called XXXX.module and paste in the following text (watch out for the XXXX):

<?php

/**
* Valid permissions for this module
* @return array An array of valid permissions for the onthisdate module
*/
function XXXX_perm() {
  return array('Access webform / panel fix.');
}

and then paste the text from the original answer below that, making sure to replace:

function bluerinse_form_alter(&$form, $form_state, $form_id)

with

function XXXX_form_alter(&$form, $form_state, $form_id)

where obviously XXXX will be the name of your module.

That should be it although you might need to give permission for everyone to use your module. Hope that helps.

thanks for taking my

headkit's picture

thanks for taking my hand...
i will try!

isn't it also possible to but

headkit's picture

isn't it also possible to put the function into the template.php of the zen-theme, in the hook-funktion

/**
* Implementation of HOOK_theme().
/
function ibomo_theme(&$existing, $type, $theme, $path) {
  $hooks = zen_theme($existing, $type, $theme, $path);
  // Add your theme hooks like this:
  /

  $hooks['hook_name_here'] = array( // Details go here );
  */
  // @TODO: Needs detailed comments. Patches welcome!
  return $hooks;
}

unfortunetly its not working

headkit's picture

unfortunately its not working with panels 3...
:-(

any suggestions? anyone? who

headkit's picture

any suggestions?
anyone?
who knows,
who knows?

This solution worked for me

baldursson's picture
  1. Go to Form Settings for your Webform
  2. Check "Available as block" under advanced settings
  3. Put the block in the panel instead of the Webform node

Just be sure to also change the redirect location for the webform.
I set it to No redirect, and it works like a charm. Shows my custom message
on the panel page and everything.

Cheers!

Flawless

fjcero's picture

Thanks for the idea, i dont think about this solution. Pretty simple and extra-module-less install requiered :)

Nice brainstorming thread (?)

Not working for me

malancheril's picture

This seems like the correct route to go. But I followed all these steps and after the form submission, the user leaves the page and the confirmation is presented on the original form node. I am using Panels 6.x-3.x-dev and Webform 6.x-3.14.

The form is available as a block and embedded within a pane in my layout. The redirect is set to "No redirect". Any suggestions?

Edit: BTW, I also tried this outside of panels by just putting the block version of the web form in a region on the blocks page. So I don't think this issue is use limited to panels usage.

Got it to work

willemviljoen's picture

After making the webform available as a block, removing the redirect and placing it in a panel.

Go to the settings of the new block and tick "Show all webform pages in block"

Now when you click on submit in a incomplete form it remains on the current page

Thanks!

utneon's picture

This one worked for me too!
Thanks!

Got it to work as well

karenann's picture

I'm using Drupal 7.22, Panels 7.x-3.3 and a super messy set of templates (I'm on damage control from a previous "developer").

After performing the actions in:
http://groups.drupal.org/node/27232#comment-426154

I went onto perform the actions in:
http://groups.drupal.org/node/27232#comment-719019

Thanks to both of you! Brilliant!

Easiest Solution

farshidam's picture

Hi,

to show the successful message just put a variable like success=success in after the Custom URL? then add sutom message to template.php of your page.

Easiest-est Solution

papagrande's picture

I found that with the lasted 7.x Panels and Webforms modules confirmation messages were showing at the top of the page without having to write code or set as a block. (You do have to turn off redirection).

Just put the "Node being viewed" content pane in your Panel content and all your Webforms can have the same look and feel. You can also place the System Messages pane wherever you want for greater control over where you want the messages to appear.

DrupalHK

Group categories

HKDUG Vocabulary

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: