Closed (fixed)
Project:
Simple Dialog
Version:
7.x-1.0
Component:
Documentation
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2011 at 08:54 UTC
Updated:
19 Jun 2013 at 01:55 UTC
I've got my Webform to work nicely with the Simple Dialog. Thanks for this great little module which is very simple to use.
When the Webform is submitted, the confirmation URL is displayed in the original browser window from which the Simple Dialog was launched. I would prefer the confirmation URL to be displayed in the Simple Dialog window instead.
#1196150: Example to display webforms (webform.module) within CTools modal windows gives a description of how this can be achieved using Ctools. Is something similar possible with Simple Dialog?
Comments
Comment #1
drclaw commentedCurrently there is nothing built into simple dialog to put the confirmation directly in the dialog window. Although, it is something I've been thinking about building into it. I would like it to be simpler than the solution in the link you provided. I've changed the ticket type to 'Feature Request' and I'll try to sit down with this sometime soon to see how I can streamline this process.
Comment #2
lock2007 commentedIs there a method to focer open the page after posting (ie in the
).
in other words: I am in the page that it openend with simple-dialog when I click submit, I send the parameters to the page (that is in the "action" attribute of
tag) to open it also in a simple-dialog?
Comment #3
drclaw commentedThere is no method currently to open the confirmation page within the modal. I am working on it though.
Comment #4
mgladding commentedI am looking for something similar. Is there away to show the error messages inside the modal?
Thanks in advance for any help!
Comment #5
drclaw commentedI've looked into this one a bit more since the issue was originally posted. It's a little trickier than I originally thought. The best solution is probably to use a ctools modal window and some form of the method described in #1196150: Example to display webforms (webform.module) within CTools modal windows. Because of this, however, it might take me a little while to get it working in this module (of course patches are welcome!)... Although I'm now wondering if this is better suited for a different module since this one is really just a simple implementation of jquery ui dialog, whereas the webform thing would be a ctools modal implementation... any thoughts?
Comment #6
carvalhar commentedHi,
I have a webform with Webform Validation and it opens inside Simple Dialog and everything occurs (ok and error messages) inside the dialog =)
I had to do some changes in webform configuration, tpls and a javscript (inside my theme).
Here's my solution:
1- Simple Dialog button configuration:
<a class="simple-dialog" href="MY_URL" name="node-MY_WEBFORM_NID" title="Webform">Open</a>2 - Webform configuration
At your webform configuration (node/MY_WEBFORM_NID/webform/configure), chose to redirect to the same node url (eg. node/MY_WEBFORM_NID) . With this you always force to have a html id for the main div presented in node.tpl (eg.: div id='node-MY_WEBFORM_NID'). This id was used as 'name' in Simple Dialog button. Also you should add a confirmation message to be shown upon successful submission.
3- TPL theming
Drupal messages (validation errors or sucessful submission) exists only at page.tpl but i need to print them on node.tp, inside the main div. So you need to make this variable global at page.tpl and print it in node.tpl. Add these two codes:
3.a - page.tpl.php:
3.b - node.tpl.php:
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>></div>3- Javascript (jQuery/Ajax)
Add a similar javascript code o your theme javasscript file:
Hope this can help someone else ;)
Bye
Carlos
PS: if inside your modal all the main content can appear again, you won't need to load messages inside node.tpl, you can open directly the main div from page.tpl, but if you do so, you'll have to print everything else, as blocks, title, breadcrumbs...
Comment #7
sakadava commentedHi Carlos,
Your post #6 worked well for me and I really appreciate your feedback on this issue.
I am using the Omega theme so this had to be adapted slightly. For example $messages are already in the right place and I changed:
to
I also added a formatter and automated the generation of the Javascript in a custom module so the administration interface can be used to configure the popup.
drclar: I'm leaving the original issue open as a feature request for now because I think it could be useful to integrate nicer Webform functionality into Simple Dialog. However Carlos's suggestion has resolved this for me, so leave open or close as you see fit.
Simon
Comment #8
elianhi commentedCarlos,
Your code worked for me. But a question: the form is rendered again. Is it possible to only show the confirmation message?
Thanks,
Elian
Comment #9
sakadava commentedHi Elian,
Like you I didn't want the form rendered again so I simply set the webform redirection location to a custom URL and this worked just fine, after ensuring the container for the custom content was specified correctly in this statement:
Hope that helps,
Simon
Comment #10
carvalhar commentedYou both need to pay attention if the form isn't validated...
Aren't you using any kind of validation? If you aren't, it's safe to redirect to other page.
But if you are, you'll need to display the form again. Because sometimes the user will type an incorrect email for example, and the message will point him to edit the email field and no webform is sent until validation is fine.
Comment #11
sakadava commentedHi Carlos,
Thanks for following this up. This does seem to work fine. When form validation fails, the form is redisplayed in the popup along with the associated message. When form validation succeeds, the redirected page is displayed in the popup.
Previously I was dealing with this using Ctools and a form built in a custom module, but being able to do this using Webform and your mechanism really helped, so thanks again.
Simon
Comment #12
carvalhar commentednice, i didn't try this before.
In my case i had to add a nofollow to robots to avoid search mechanisms indexing the 'thank you' page.
Comment #13
drclaw commentedThis isn't something that is easily done and is probably outside the scope of a "simple" dialog. The solution in #6 is pretty good in the interim but requires you to write your own javascript which kind of defeats the purpose of this module. If you know how to do a jQuery ajax call, you may as well script your own dialog as it could be more flexible and possible perform better. =)
Comment #14
gerrit1978 commentedthis one saved my life :)
Comment #15
Teresa_ commentedI hope it is okay to continue this thread since it is old but I would really like to talk with someone who has more experience with this. I have this working with Omega and #6 solution but I am finding it writes to the webform results database twice. I took my extra validation module out because I thought it was contributing to the issue. Need help putting that back in and stopping the errant POST from my custom module. But lets start with why this code rewrites to the database.
Thanks
Teresa_
Comment #16
drclaw commentedHi,
My guess would be that the click event handler is being attached twice to the button. Is your code in a Drupal.behavior? You could try using jQuery once to ensure the click handler only gets applied once.
Alternatively, have you tried Modal Forms? It works quite well with webforms. It might work for you.
drclaw
Comment #17
Teresa_ commentedIt had something to do with the validation. Didn't try Modal Forms but I am very fond of Webform. I am still trying to figure out the array that defines the order of events on the form submission. This is critical to getting the validation in the right place and not logging in the db twice.
Thanks,
Teresa
Comment #18
drclaw commentedJust to clarify, Modal Forms works with webforms. Your existing webforms don't have to change. You would just create the links that launch the modal differently. Here's the documentation
Comment #19
Teresa_ commentedOnce I catch up I want to try a side by side comparison to see if modal forms is faster than my solution. I find there is a little hesitation with simple dialog. Thanks drclaw.!
Comment #19.0
Teresa_ commentedFixed format of referenced issue