Skip to content

Conversation

@ale-rt
Copy link
Member

@ale-rt ale-rt commented May 9, 2025

Fixes #29

@mister-roboto
Copy link

@ale-rt 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!

@ale-rt
Copy link
Member Author

ale-rt commented May 9, 2025

@jenkins-plone-org please run jobs

@ale-rt
Copy link
Member Author

ale-rt commented May 9, 2025

@ale-rt ale-rt requested a review from mauritsvanrees May 9, 2025 14:36
Copy link
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

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

It seems something is still wrong. Using the multi field does not work, see also plone/plone.app.content#304 (review)

No content is visible while browsing for a related item. And the network tab shows a few 404s because @@getSource is called on a context that is not found:

http://localhost:8080/oira/sdaffsdasd/@@edit/++widget++form.widgets.ICaptionRelationBehavior.multi.0.widgets.relation

@mauritsvanrees
Copy link
Member

I directly visit http://localhost:8080/oira/sdaffsdasd/@@edit/++widget++form.widgets.ICaptionRelationBehavior.multi.0.widgets.caption in the browser.

While traversing, the target first is:

<plone.dexterity.browser.edit.DefaultEditForm object at 0x10760d6a0>

Then:

<MultiWidget 'form.widgets.ICaptionRelationBehavior.multi'>

Then it tries to traverse to 0, but this gives an IndexError, which is changed into a TraversalError on this line, which is reported with yet another name:

LocationError: "'0' not in range"

Not sure where to go from there.

@ale-rt
Copy link
Member Author

ale-rt commented May 12, 2025

The main issue with the widget is that it tries to do ajax calls on a URL which looks like:

  • $FORM_URL/++widget++form.widgets.$NAME.$N.widgets.relation

With $N being the subwidget.

Initially, the form field looks like this:

Image

So it has no subwidget and you get the error.

Inspecting what "Add" does, I noticed the following parameters are submitted:

form.widgets.multi.buttons.add: Add
form.widgets.multi.count: 0

They cause one more widget to be added to the list of the existing ones.

So, if you pass these parameters as well, you can properly traverse to the widget:

E.g:
http://localhost:8080/Plone/@@captioned-relation-field-test-page/++widget++form.widgets.multi.0.widgets.relation/?form.widgets.multi.count=0&form.widgets.multi.buttons.add=Add

image

I have no idea if it is worth pushing this PR further for the moment.

@ale-rt
Copy link
Member Author

ale-rt commented May 12, 2025

I actually checked how the multiwidget works and found a simple fix for that.

Solves the use case of traversing a new widget that is not initialized by
default.
This mimics what happens when you click the add button.
@ale-rt
Copy link
Member Author

ale-rt commented May 12, 2025

@jenkins-plone-org please run jobs

@ale-rt ale-rt requested a review from mauritsvanrees May 13, 2025 06:07
@ale-rt
Copy link
Member Author

ale-rt commented May 13, 2025

@jenkins-plone-org please run jobs

Copy link
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

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

I tested again, and now it works. Thanks!

@mauritsvanrees mauritsvanrees merged commit f019fa6 into master Jun 12, 2025
16 checks passed
@mauritsvanrees mauritsvanrees deleted the ale/29/fix branch June 12, 2025 13:36
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.

It is not possible to traverse a widget inside an object widget

4 participants