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
This commit is contained in:
2025-10-01 14:34:53 +02:00
parent f01024d981
commit c4308542b9

View File

@@ -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()