Fixes and improvements

* fixes group check on detail views
* adds check for required fields in BaseForm for showing required field hint or not in template
This commit is contained in:
mipel
2021-08-04 08:41:21 +02:00
parent cd5b2e264b
commit d773c3b3d4
4 changed files with 16 additions and 7 deletions

View File

@@ -37,12 +37,19 @@ class BaseForm(forms.Form):
form_caption = None
instance = None # The data holding model object
form_attrs = {} # Holds additional attributes, that can be used in the template
has_required_fields = False # Automatically set. Triggers hint rendering in templates
def __init__(self, *args, **kwargs):
self.instance = kwargs.pop("instance", None)
self.user = kwargs.pop("user", None)
super().__init__(*args, **kwargs)
# Check for required fields
for _field_name, _field_val in self.fields.items():
if _field_val.required:
self.has_required_fields = True
break
@abstractmethod
def save(self):
# To be implemented in subclasses!