I have a few behaviors created via plonecli. Plonecli creates behaviors with a separate marker interface and factory out of the box.
I have a few RelationList fields on some of them.
I noticed my custom relations does not get added correctly on object add, as can be seen in the inspect-relations view of collective.relationhelpers (this is such a super helpful addon!)
When I edit the just added object, the relations are updated correctly and shows up in the inspection view.
The relatedItems behavior does work correctly on add, and the reason for that is that the marker interface and the formfieldprovider interface is the same. No separate marker, and no factory.
In plone.app.relationfield update_behavior_relations is registered for IObjectModifiedEvent.
(The edit-part that works.)
z3c.relationfield registers addRelationsEventOnly for IIntIdAddedEvent. But the _potential_relations function traverses over the objects providedBy(obj) interfaces - this only includes the marker interfaces not the formfield providers when the two are separate. I guess that could be part of the reason for the update_behavior_relations registration.
But to make this work when adding objects, we need to register update_behavior_relations for IIntIdAddedEvent too (not for IObjectCreatedEvent, that wont work - too early I guess?)
<subscriber for="plone.dexterity.interfaces.IDexterityContent zope.intid.interfaces.IIntIdAddedEvent" handler="plone.app.relationfield.event.update_behavior_relations" />
With this fix it works.
Is this a know bug? If so where would I find the ticket? (What repo - CMFPlone?). I could even make a PR but the creation of a test to cover this seems a little daunting...