-
-
Save quevon24/92fdbcc722217f4aeeec99001cbdacff to your computer and use it in GitHub Desktop.
Hidden delete inline formset base class for Django.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HiddenDeleteBaseInlineFormSet(BaseInlineFormSet): | |
""" | |
Makes the delete field a hidden input rather than the default checkbox | |
inlineformset_factory(Book, Page, formset=HiddenDeleteBaseInlineFormSet, can_delete=True) | |
""" | |
def add_fields(self, form, index): | |
super(HiddenDeleteBaseInlineFormSet, self).add_fields(form, index) | |
if self.can_delete: | |
form.fields[DELETION_FIELD_NAME] = forms.BooleanField( | |
label=_('Delete'), | |
required=False, | |
widget=forms.HiddenInput | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment