Daniel Hernández
Daniel Hernández

Reputation: 1317

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.

Upvotes: 2

Views: 201

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1124798

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"),
        ))

Upvotes: 5

Related Questions