django inline formset id: * this field is required.

0


By default  django-crispy-forms  renders the layout specified if it exists strictly. Sometimes you might be interested in rendering all form’s hidden fields no matter if they are mentioned or not.

So we get an error like:
formset id: * this field is required.


We can set render_hidden_fields an attribute of Form Helper to True.


from crispy_forms.helper import FormHelper

class FormHelperWithHiddenFields(FormHelper):
    form_tag = False
    field_class = "mb-4"
    # Required to render hidden fields to prevent >id: this field is required.
    render_hidden_fields = True

Useful when trying to render forms with layouts as part of a formset with hidden primary key fields.

Post a Comment

0 Comments

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

This site uses cookies from Google to deliver its services and analyze traffic. Your IP address and user-agent are shared with Google along with performance and security metrics to ensure quality of service, generate usage statistics, and to detect and address abuse. More Info
Ok, Go it!