conjunto.forms
¶
conjunto.forms.DynamicHtmxFormMixin
¶
Bases: DynamicFormMixin
Mixin class for creating dynamic forms with HTMX.
This mixin extends the functionality of the DynamicFormMixin by adding htmx attributes to the form fields that can be used for triggering dynamic updates.
| Attributes: |
|
|---|
| Raises: |
|
|---|
fields_required(fields, msg=None)
¶
Helper method used for conditionally marking fields as required.
| Parameters: |
|
|---|
Example usage:
def clean(self):
is_person = self.cleaned_data.get("is_person")
if is_person:
self.field_required(["first_name", "last_name"])
self.field_required("title", "A title is definitely required here.")
self.field_required(["age", "size"], "You forgot this field.")
else:
self.cleaned_data["first_name"] = ""
self.cleaned_data["last_name"] = ""
self.cleaned_data["title"] = ""
return self.cleaned_data
Credits go to https://www.fusionbox.com/blog/detail/creating-conditionally-required-fields-in-django-forms/577/
conjunto.forms.ErrorLogMixin
¶
A mixin that can be added to a Form during development/debugging, so that it logs all form errors.
conjunto.forms.MyDynamicFormMixin
¶
A mixin class for Django forms that allows dynamic fields to be included or excluded based on certain conditions.
| Attributes: |
|
|---|