From c4308542b92b95518571bc2a708d4a2a971c2a2a Mon Sep 17 00:00:00 2001 From: Jan Remmer Siebels Date: Wed, 1 Oct 2025 14:34:53 +0200 Subject: [PATCH] Fix disabled date field to show current value when editing - Set initial value for disabled faellig_am field in auto-generated payments - Explicitly set widget value attribute to display current date - Ensures the field shows the correct date even when disabled --- app/stiftung/forms.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/stiftung/forms.py b/app/stiftung/forms.py index 529de31..93d8059 100644 --- a/app/stiftung/forms.py +++ b/app/stiftung/forms.py @@ -1005,6 +1005,11 @@ class DestinataerUnterstuetzungForm(forms.ModelForm): self.is_auto_generated = True self.fields['faellig_am'].disabled = True self.fields['faellig_am'].help_text = "Fälligkeitsdatum wird automatisch basierend auf Quartal berechnet" + # Ensure the initial value is set for disabled field and widget shows the value + self.fields['faellig_am'].initial = self.instance.faellig_am + self.fields['faellig_am'].widget.attrs.update({ + 'value': self.instance.faellig_am.strftime('%Y-%m-%d') if self.instance.faellig_am else '' + }) def clean(self): cleaned_data = super().clean()