covid-videoplattform / django-webfrontend

webbased room and appointment management system
MIT License
1 stars 0 forks source link

appointment creation form: use date/time select fields #6

Open fargerio opened 4 years ago

fargerio commented 4 years ago

maybe duration instead of end time?

ghost commented 4 years ago

i think duration is better

fargerio commented 4 years ago

I'm trying to customize the form fields, but the ModelForm seems to ignore all my efforts:

https://github.com/covid-videoplattform/django-webfrontend/blob/124311b42c688df6868da35d1222f22e0429a110/rooms/forms.py

class AppointmentForm(forms.ModelForm):
    # i'm trying to customize form fields, but nothing is working:

    # first way
    description = forms.CharField(widget=forms.Textarea(
            attrs={'class': 'test1', 'maxlength': 123, 'rows': 40})),

    # second way
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['description'].widget = forms.Textarea(
            attrs={'class': 'test2', 'maxlength': 155, 'rows': 4})

    class Meta:
        model = Appointment
        fields = ['name', 'description',
                  'start_time', 'end_time', 'staffmember', 'room_name']
        # third way
        widgets = {
            'description': forms.Textarea(attrs={
                'class': 'test3', 'cols': 20, 'rows': 20}),
        }

any ideas?

fargerio commented 4 years ago

The problem was that I was also setting fields = […] on the CreateView, and those override any configuration I do in AppointmentForm.