Download & Extend

Lightframe/lightmodal for a node with a form

Project:Lightbox2
Version:6.x-1.9
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

I'm messing around with lightbox2 but can't get the functionallity i'm after:

I want a lightbox (lightframe/lightmodal) to open with an invite node, which i customized to look like "/invite?path=user/x". After submitting the node, using that link, i would like the lightbox to close.

I tried lightmodal, but after the node loads it instantly closes and redirects to the front page.
I tried lightframe, but after submitting the node it stays open and shows the front page.

Is there a way to set a lightframe to close after submitting a form? i understand that's what lightmodal is for, but i can't get it to display the node correctly.

Any ideas?

Comments

#1

There's no way to get lightframe to close after submitting a form. You should use lightmodal to do this. However, when doing this you need to ensure that you're not loading the full html page in the lightmodal - just load the div / form / html snippet that you're interested in.

For redirecting to front page - you can tell Drupal forms where to redirect after the form is submitted. If it's not one of your module's forms, then use hook_form_alter() to change the redirection setting.

Cheers,
Stella

#2

Status:active» closed (works as designed)

I understand the correct way to go is to use the Lightmodal.

Problem is i can't figure out how to load this Tell A Friend node, which in it's "View" state (as opposed to edit) has a form in it for users to submit, without loading the full page. I get even more lost when trying to figure out how to add the "?path=..." correctly this way.

But i guess this is more of a Tell A Friend.module issue...

Thanks Stella!

#3

maybe check out drupal_get_form() - see api docs on http://api.drupal.org

Cheers,
Stella

#4

It's actually fairly easy to perform this as I discovered. The issue is getting the JS of the CCK fields to work. If you poked around the issue queue, you'll see that lightbox can open a CSS ID (and class too, I think). Kinda like this:

<a href="/node/add/story #node-form" rel="lightmodal">Add Story type</a>

This will open up the node form, and everything submits just fine. The problem at the moment that I am having is that there doesen't seem to be support for javascript in the modal. Fieldsets wont collapse/expand, cck date picker widgets don't work, and autocompletes also do not work - but everything else works just fine.

@Stella, is there a way to get around this? I mean honestly I spent the last 6 months trying to figure out how to get forms into a modal box, and now that this method is so unbelievably simple to do I'd hate to have it fall flat on its face because theres no JS support in lightmodal. Am I doing something wrong? This could have potential to be really cool!

Thanks!

#5

I'm having this issue as well trying to get Inline Ajax Search to open in a LightModal.

#6

I've found a quick and dirty solution to close the lightframe after form is submitted. It's not optimal but it fits my needs, as the visitor does not see anything but the lightbox being closed after the form is processed.

Webform 2.9 has a setting "Confirmation message or redirect URL", where I drop the absolute path to an html file containing this line:

<script type="text/javascript">window.parent.Lightbox.end();</script>

Which fires the closing event of the lightbox containing the iframe. I hope somebody in a hurry can find this solution useful, but feel free to improve it and post.

#7

I realize this is a closed issue, but wanted to point out that trying this in Drupal 7 results in a en empty modal.

nobody click here