2

I have created a form using PloneFormGen tool. Now I would like to display this form in a popup in a manner similar to the login form is displayed on click of a button. I've looked into the jquery tools module that give me the option to load a url/ajax forms in a popup. I tried to load the url in iframe but it displays the entire page in the pop-up. I only need the form section to be displayed. Do I need to customize the plone formgen form in some way so that the jquery tools understands it? Or do I need to create the forms in some other manner? The point is I need the mailer functionality also once my form is successfully submited so Plone FormGen fits the requirement in this case. Any guidance/pointers on this would be helpful. Do suggest some pointers.

Avinash
  • 33
  • 4
  • It seems that you are not using the proper jquery selector to pick up the form. Could you post your code (only the part for the popup) so that we can fix it? – Giacomo Spettoli Jan 20 '12 at 11:07
  • My javascript is as follows: jq(document).ready(function(){ jq('#view_screenshot').prepOverlay({subtype: 'iframe', urlmatch:'home/view-screen-shots', formselector: 'form'}); }); The error I get is: Error: this.getContent is not a function Source File: www.example.com/Home/portal_javascripts/My%20Theme/++resource++plone.app.jquerytools.overlayhelpers.js I'm calling this function on click of a image. – Avinash Jan 20 '12 at 11:42

2 Answers2

4

Take a look at the way Plone sets up its own popup forms in plone_ecmascript/popupforms.js. It'll show you several really working examples of how to do popup forms. For example, the contact form setup:

// contact form
$('#siteaction-contact a').prepOverlay(
    {
        subtype: 'ajax',
        filter: common_content_filter,
        formselector: 'form[name="feedback_form"]',
        noform: function(el) {return $.plonepopups.noformerrorshow(el, 'close');}
    }
);

PFG forms are no different. Note the "filter" specification: that's what makes sure you don't show more of the page than you wish. That kind of filtering is possible in an AJAX popup, but not an iframe.

Full details at http://pypi.python.org/pypi/plone.app.jquerytools/1.4b1

SteveM
  • 6,058
  • 1
  • 16
  • 20
  • Steve,I tried the solution but when i change the subtype to ajax i got this message "No response from server. Please try again later. " jq('#view_screenshot').prepOverlay({subtype: 'ajax',filter: common_content_filter, formselector: 'form[name="edit_form"]', noform: function(el) {return jq.plonepopups.noformerrorshow(el, 'close');} });Whenerver i create a form using a plone form gen i always get the same name attached with the form. So currenlty i can't distinguish my differnt forms that i have create is there any mechanism to give differnt form name while creation of a form – Avinash Jan 21 '12 at 07:33
  • The selector in the jq() part needs to point to a link to a form page. I suspect yours is not. If you follow that link (without prepOverlay engaged), it should display your form page. The prepOverlay routine sets it up to display the form instead. PFG forms post to themselves. They're distinguished by their URLs. – SteveM Jan 21 '12 at 16:05
  • You can use the embeded mode of Plone formgen using jquerytools. The url used in the iframe must be yourform/fg_embedded_view_p3 – toutpt Jan 21 '12 at 18:33
  • Thanks toutpt it worked! but when i submit the form, after validation failure the form is not get rendered in embedded view.How can i show the form with errors in embedded view ? – Avinash Jan 23 '12 at 06:25
0

You might take a look at Popup Forms for Plone: http://plone.org/products/pipbox.portlet.popform

Davi Lima
  • 800
  • 1
  • 6
  • 20