Skip to content

toWidget method of a custom converter is not executed #218

@holdenhao

Description

@holdenhao

I am using Plone 6.0.15 ClassicUI and DGF 3.0.4. My custom converter for my schema.Decimal field is not being triggered in display mode.

My DictRow schema:

class IOrderDetails(model.Schema):

    order_category = schema.Choice(
        title="Category",
        vocabulary="srstims.common.OrderCategory",
        required=False,
    )

    directives.widget("amount", DecimalCurrencyTextFieldWidget)
    amount = schema.Decimal(
        title="Amount",
        required=False,
    )

My converter:

@adapter(IDecimal, IDecimalCurrencyTextWidget)
class DecimalCurrencyTextDataConverter(BaseDataConverter):

    def toWidgetValue(self, value):
        if value is self.field.missing_value:
            return ""
        return str(value)

The converter works on regular schema fields but not if it is used in DGF.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions