Skip to content

Handle fieldset fields in the content rules control panel - #2056

Merged
davisagli merged 4 commits into
mainfrom
issue-2016
Oct 12, 2026
Merged

davisagli merged 4 commits into
mainfrom
issue-2016

Conversation

@ericof

@ericof ericof commented Sep 25, 2026

Copy link
Copy Markdown
Member

Fields that a content rule condition or action declares in a non-default fieldset(...) were listed in @schema, but @controlpanels/content-rules did not read or write their values.

The edit and add forms of rule elements are not group forms, so plone.autoform puts those fields on form.groups instead of form.fields. The control panel only looked at form.fields, so:

  • GET .../<rule>/action/<idx> (and condition/<idx>) omitted their values;
  • PATCH silently ignored them;
  • POST (adding an element) silently ignored them too. The issue doesn't mention this case, but it has the same cause.

Changes

  • Fix (b81e887): a new include_fieldset_fields(form) helper adds the fields of all fieldsets to form.fields before values are read or applied, in add, get and update. It keeps the existing z3c.form path, so applyChanges, the ObjectModifiedEvent and the target_folder UUID handling behave as before.

  • Refactor (266a19d), with no behavior change:

    • add, get, update and delete become small dispatchers on the URL path segments, with private helpers for each operation;
    • the CSRF, element lookup and edit form code is now shared;
    • added type hints and reST docstrings;
    • error messages use f-strings.

    The generated http-examples are unchanged.

Tests

test_controlpanels_content_rules.py registers a test-only rule action whose schema has an "advanced" fieldset, in its own layer, so the documented addable_actions don't change. It covers GET, POST and PATCH of fieldset fields. All three tests fail without the fix (KeyError: 'extra_title').

Full suite: 1409 tests, 7 failures. These are the pre-existing date/time failures I also get on main.

Closes #2016

The edit and add forms of content rule conditions and actions are not
group forms, so plone.autoform puts fields declared in a non-default
fieldset on form.groups instead of form.fields. Getting, adding and
updating a condition or action therefore ignored those fields, even
though @Schema listed them.

Merge the fields of all fieldsets into the form fields before reading
or applying values.

Closes #2016
Split add, get, update and delete into small dispatchers on the URL
path segments, with private helpers for each operation. Share the
CSRF protection, element lookup and edit form setup between them.

Also add type hints and reST docstrings, raise NotFound when the
add view of a rule or element cannot be found, and use f-strings for
error messages. The API responses are unchanged.
@mister-roboto

Copy link
Copy Markdown

@ericof thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@ericof

ericof commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

@jenkins-plone-org please run jobs

plone.z3cform is not a declared dependency, and z3c.dependencychecker
also scans imports guarded by TYPE_CHECKING. FormWrapper subclasses
Products.Five's BrowserView, which Zope provides.
@ericof

ericof commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

@jenkins-plone-org please run jobs

@ericof

ericof commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

News fragment is present, no idea why Mr. Roboto is complaining about it

@davisagli davisagli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericof Sorry for my slow review. Looks good, and thank you.

@davisagli
davisagli merged commit 2b84de9 into main Oct 12, 2026
10 of 14 checks passed
@davisagli
davisagli deleted the issue-2016 branch October 12, 2026 04:19
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

Successfully merging this pull request may close these issues.

@controlpanels/content-rules/<rule>/action/<idx> omits values for fields in non-default fieldsets

3 participants