How to use ILanguageIndependentField on a field using a widget?

Hello,
I'm trying to customize the behaviour of the Event type. I need to make some fields language independent.

I added this to the setuphandlers.py

from zope.interface import alsoProvides
from plone.app.multilingual.dx.interfaces import ILanguageIndependentField
from plone.app.event.dx.behaviors import IEventBasic
from plone.app.event.dx.behaviors import IEventContact
from plone.app.event.dx.behaviors import IEventAttendees
from plone.app.event.dx.behaviors import IEventRecurrence
from plone.app.contenttypes.behaviors.leadimage import ILeadImage


alsoProvides(IEventBasic['start'], ILanguageIndependentField)
alsoProvides(IEventBasic['whole_day'], ILanguageIndependentField)
alsoProvides(IEventBasic['open_end'], ILanguageIndependentField)
alsoProvides(IEventContact['contact_name'], ILanguageIndependentField)
alsoProvides(IEventContact['contact_email'], ILanguageIndependentField)
alsoProvides(IEventContact['contact_phone'], ILanguageIndependentField)
alsoProvides(IEventAttendees['attendees'], ILanguageIndependentField)
alsoProvides(IEventRecurrence['recurrence'], ILanguageIndependentField)
alsoProvides(ILeadImage['image'], ILanguageIndependentField)

On a text field like IEventContact['contact_name'] it works just fine however on IEventBasic['start'] it doesn't. The difference is that this field is defined as a widget in the behavior.

@adapter(getSpecification(IEventBasic['start']), IPloneFormLayer)
@implementer(IFieldWidget)
def StartDateFieldWidget(field, request):
    widget = FieldWidget(field, DatetimeWidget(request))
    widget.default_timezone = default_timezone
    return widget

Anyone knows how to fix it?

Thanks

I guess you read this? https://docs.plone.org/external/plone.app.multilingual/README.html#adapt-all-the-steps-on-translation

There are quite a few people who use p.a.multilingual who should be able to help you.

We just added languageindependent fields to IEventBasis as the default https://github.com/plone/plone.app.event/commit/651f14cd40de05703a772daf24d132a884f242dc

1 Like