collective / collective.easyform

Forms for Plone
https://pypi.org/project/collective.easyform
13 stars 29 forks source link

ReferenceError: copyDataForSubmit is not defined #29

Open davilima6 opened 8 years ago

davilima6 commented 8 years ago

Tested in latest release, 1.0.3, with shipped Plone 4.3.9 buildout.

Steps to reproduce:

  1. Run the bootstrap and buildout scripts included in the package. You'll have to comment the entire [parts] section because of outdated pins.
  2. Start instance and add a site with EasyForm addon.
  3. Add an EasyForm item with default settings.
  4. Go to its Fields or Actions tab.
  5. Click Settings link.
  6. Notice error: no popover opens, spinner never stops and you see the Reference error in browser's console, which traces back to copyDataForSubmit('form-widgets-IFieldExtender-validators'); as used in ++resource++plone.app.jquery.js%20line%202%20%3E%20eval:1:1a:

Not sure if related but I also fail when trying to add a custom field in Site Setup > Dexterity Content Types. I do get the popover but after filling the fields and clicking Add I always get the same traceback regardless of the chosen Field type:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module plone.z3cform.layout, line 66, in __call__
  Module plone.z3cform.layout, line 50, in update
  Module z3c.form.form, line 228, in update
  Module plone.app.z3cform.csrf, line 21, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 315, in __call__
  Module z3c.form.button, line 170, in __call__
  Module z3c.form.form, line 257, in handleAdd
  Module z3c.form.form, line 265, in createAndAdd
  Module plone.schemaeditor.browser.schema.add_field, line 46, in add
  Module zope.event, line 31, in notify
  Module zope.component.event, line 24, in dispatch
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module zope.component.event, line 32, in objectEventNotify
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module plone.app.dexterity.serialize, line 22, in serializeSchemaContext
  Module plone.supermodel, line 40, in serializeModel
  Module plone.supermodel.serializer, line 116, in serialize
  Module plone.supermodel.serializer, line 70, in writeField
  Module plone.supermodel.exportimport, line 200, in write
  Module plone.supermodel.exportimport, line 240, in writeAttribute
  Module plone.supermodel.exportimport, line 420, in write
NotImplementedError: Choice fields with vocabularies not based on a simple list of values or a named vocabulary cannot be exported

The Site Setup > Dexterity instance of plone.schemaeditor works flawlessly when I use my own (mr.bob-generated) Plone 4.3.9 buildout. Still, Easyform's Settings links don't.

Does anyone confirm this issue? Is there any fix available?

davilima6 commented 8 years ago

It looks like for some reason orderedselect_input.js is not being loaded (should it be inside the popover?). But then again I don't see it in Site Setup > Dexterity > Fields > Settings either.

fredvd commented 8 years ago

@davilima6 . Did you find out more? I'm running into the same copyDataForSubmit error on a collective.cover settings form where an overlay should pop up. This is also after upgrading the project to Plone 4.3.9 . Might be related to z3.form updates in Plone.

davilima6 commented 8 years ago

@fredvd, nothing else so far.

fredvd commented 8 years ago

@davilima6 As a work around: you can try to add ++resource++orderedselect_input.js to the portal_javascripts.js so that it is always loaded. This works for our collective.cover similar issue.

The problem seems to indicate that plone.app.jquerytools .prepOverlay copies only part of the XHR loaded popup form and for some reason the part of the ordered_select_input.pt html is never found or loaded by the browser.

The annoying part is that I tried to reason about which change/version update in the stack is responsible for this change in behaviour, but so far not a single package stands out as having fixes or updates in this area. I've pinned back several packages to their Plone 4.3.7 state or before, but nothing so far, except for this workaround.

tomgross commented 7 years ago

I have the same issue in the babel_view of plone.app.multilungual.

maethu commented 7 years ago

The problem is that jquery does stript script tags if you use load with a selector:

This is from the jquery documentation:

Script Execution

When calling .load() using a URL without a suffixed selector expression, the content is passed to .html() prior to scripts being removed. This executes the script blocks before they are discarded. If .load() is called with a selector expression appended to the URL, however, the scripts are stripped out prior to the DOM being updated, and thus are not executed. An example of both cases can be seen below:

Here, any JavaScript loaded into #a as a part of the document will successfully execute.

  1. $( "#a" ).load( "article.html" );

However, in the following case, script blocks in the document being loaded into #b are stripped out and not executed:

  1. $( "#b" ).load( "article.html #target" )

This needs to be integrated somehow.

By subscribe the onLoad method, or prepOverlay loads the orderedselect_input.js too?

fredvd commented 7 years ago

@maethu Thank you very much for figuring this out! We've been chasing this issue in collective.cover as well and there are probably other add'ons where this happens. (i.e. any form in Plone with complex widgets loading in a .prepoverlay'ed screen.

It's at least something that could hopefully be added to .prepOverlay from plone.app.jquerytools. I can use a bit of javascript, but cannot develop for it.