I am using a RelationChoice field as follows:
directives.widget("field_name", SelectFieldWidget)
field_name = RelationChoice(
title="Field Name",
vocabulary="someVocabularyName",
required=False,
)
And I use the SelectFieldWidget for the Add and Edit forms. However, for the display or browser view, I want to use another widget which will render the value with a link to the target. I tried using the updateWidgets method below but it does not work.
from plone.dexterity.browser.view import DefaultView
class ItemView(DefaultView):
def updateWidgets(self, prefix=None):
super().updateWidgets()
self.fields["field_name"].widgetFactory = RelatedItemsFieldWidget
Using pdb and setting the widgetFactory, the field still uses the SelectFieldWidget.
(Pdb++) self.fields['field_name'].widgetFactory
{'display': ParameterizedWidget(<function SelectFieldWidget at 0x75122720c9a0>, {})}
In my template, I am calling the widget via:
<span tal:replace="structure widget/@@ploneform-render-widget" />
What is a way to change the widget in a browser view?