Plone- In a dexterity.AddForm, how can I include a schema.List widget that has a value_type of object?

214 views Asked by At

I have a dexterity.AddForm and I want to get a list widget to accept a value type of object.

I have an interface for the object value type:

class IMyObject(Interface):
    field_a = schema.TextLine(
        title = u"Field A",
    )

    field_b = schema.TextLine(
        title = u"Field B",
    )

Then for the dexterity content type, I have this:

class IMyContentType(Interface):
    combines = schema.List(title=_(u'List of object value type test'),
                           value_type=schema.Object(schema=IMyObject),
                           required=False,
                      )

class MyContentType(Container):
    grok.implements(IMyContentType)

My dexterity.AddForm:

class Add(dexterity.AddForm):
    grok.context(IMyContentType)
    grok.name('my.package.mycontenttype')

Unfortunately, when I go to try a submission, I get an error displayed in the widget: The system could not process the given value.

For the interface class IMyContentType, I tried model.Schema and form.Schema just to see if that would make a difference, but it didn't. I assume I might be on the wrong path. What would a better approach for trying to achieve a list that has a value type of object?

0

There are 0 answers