inostia
inostia

Reputation: 8023

Require at least one MultiFieldPanel object [wagtail]

I have a content_panels definition that includes this:

MultiFieldPanel(
    [
        InlinePanel('related_resource_type', label="Resource Type",),
    ],
    heading="Resource Type",
    classname="collapsible"
),

This references

class RelatedResourceType(Orderable):
    page = ParentalKey('ShopPage', related_name='related_resource_type')
    resource_type = models.CharField(
        max_length=16,
        choices=shopchoices.RESOURCE_TYPE_CHOICES,
        default="shop"
    )

Is there a way in Wagtail to require at least one RelatedResourceType? Preferably I would also have the ability to specify a minimum number of RelatedResourceTypes. I cannot find in the documentation how to specify required panels. Thanks in advance.

Upvotes: 1

Views: 169

Answers (1)

nimasmi
nimasmi

Reputation: 4138

InlinePanel takes an optional min_num argument.

Finally, min_num and max_num allow you to set the minimum/maximum number of forms that the user must submit

From http://docs.wagtail.io/en/v1.10.1/reference/pages/panels.html?highlight=min#inline-panels-and-model-clusters

Upvotes: 2

Related Questions