Search code examples
plonedexterity

Multivalued attributes in Dexterity


With Dexterity I can create a model of contact cards having an email attribute.

class IContact(form.Schema):
    email = schema.TextLine(
            title=_(u"Email"),
            description=_(u"Contact email"),
        )

How can I modify this schema to have multiple emails for each contact? I know that it is possible to add emails as a nested content type. Thus, my question is if Dexterity supports multivalued attributes inside content types.


Solution

  • Sure it does, wrap the email TextLine in a schema.List:

    schema.List(
            title=u"Email adresses",
            required=False,
            value_type=schema.TextLine(
                title=_(u"Email"),
            ))