Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Exception after changing the field id when the save data action has a defined set of fields to save #381

Open
frapell opened this issue Nov 24, 2022 · 0 comments

Comments

@frapell
Copy link
Member

frapell commented Nov 24, 2022

Steps to reproduce:

  1. Create a Form
  2. Go to "Actions" -> "Define form actions"
  3. Add a "Save Data" action (mailer can be removed)
  4. Go to "Settings..." for the new action
  5. Under the "Saved fields" choose all fields (This step is important)
  6. Click "Save"
  7. Go back to the form in "view" mode and enter some test data
  8. Go to "Actions" -> "Saved data"

At this point, the data entered in step 7 should be visible and a CSV can be downloaded. So now:

  1. Go to "Actions" -> "Define form fields"
  2. Remove the "topic" field
  3. Go to "Actions" -> "Saved data"

An exception is raised

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 359, in publish_module
  Module ZPublisher.WSGIPublisher, line 262, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 63, in call_object
  Module collective.easyform.browser.actions, line 203, in __call__
  Module plone.z3cform.layout, line 63, in __call__
  Module plone.z3cform.layout, line 47, in update
  Module plone.z3cform.crud.crud, line 386, in update
  Module plone.z3cform.crud.crud, line 209, in update
  Module plone.z3cform.crud.crud, line 218, in _update_subforms
  Module z3c.form.form, line 226, in update
  Module plone.z3cform.patch, line 20, in BaseForm_update
  Module z3c.form.form, line 154, in update
  Module z3c.form.form, line 136, in updateWidgets
  Module z3c.form.field, line 227, in update
  Module plone.z3cform.crud.crud, line 134, in fields
  Module collective.easyform.browser.actions, line 144, in update_schema
  Module z3c.form.field, line 154, in select
  Module z3c.form.field, line 154, in <listcomp>
  Module z3c.form.util, line 259, in __getitem__
KeyError: 'topic'

The reason for this is because the Save Data adapter saves the list of fields (From step 5) as a static list, so when a field is removed or its id is changed (By manually editing the XML fields model), the fields.select(*showFields) fails.

This doesn't happen when there's no field selected in the save data adapter, and so all available fields are used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant