django inline formset id: * this field is required.



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.

Comments

Popular posts from this blog

Installing the Certbot Let’s Encrypt Client for NGINX on Amazon Linux 2

psql: error: connection to server at "localhost" (127.0.0.1), port 5433 failed: ERROR: failed to authenticate with backend using SCRAM DETAIL: valid password not found

Deploy Nuxt.js app using Apache 2