diff options
Diffstat (limited to '')
-rw-r--r-- | ctrack/caf/forms.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py index 776e9af..c2d75ff 100644 --- a/ctrack/caf/forms.py +++ b/ctrack/caf/forms.py @@ -1,5 +1,5 @@ from crispy_forms.helper import FormHelper -from crispy_forms.layout import Button, Field +from crispy_forms.layout import Button, Field, Hidden from crispy_forms.layout import ButtonHolder from crispy_forms.layout import Fieldset from crispy_forms.layout import Layout @@ -21,9 +21,27 @@ CAFCreateInlineFormset = inlineformset_factory( class ApplicableSystemCreateFromOrgForm(forms.ModelForm): + + def __init__(self, org_id, *args, **kwargs): + super().__init__(*args, **kwargs) + self.helper = FormHelper(self) + self.helper.layout = Layout( + Fieldset( + "Create a new System", + Field("name", css_class="form-control form-control-sm"), + Field("description", css_class="form-control form-control-sm"), + Hidden("organisation", org_id), + Field("caf", css_class="form-control form-control-sm") + ), + ButtonHolder( + Submit("submit", "Submit", css_class="btn-primary"), + Button("cancel", "Cancel", css_class="btn-danger") + ) + ) + class Meta: model = ApplicableSystem - fields = ["name", "description", "caf"] + fields = ["name", "description", "caf", "organisation"] class ApplicableSystemCreateForm(forms.ModelForm): |