Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxDate option does not work when field is referenced in range_from #125

Open
egong340 opened this issue Jan 24, 2025 · 0 comments
Open

Comments

@egong340
Copy link

Describe the bug
I have 2 fields in my django form, start_date and end_date. The "end_date" field uses the range_from setting with a maxDate option (this works fine).
However, the "start_date" field, despite having the maxDate options, it does not set the maxDate when rendered.

    start_date = forms.DateField(
        required=True,
        widget=DatePickerInput(
            attrs={"autocomplete": "off"},
            options={
                "useCurrent": False,
                "showTodayButton": False,
                "maxDate": yesterday.strftime("%Y-%m-%d"),
                "allowInputToggle": True,
            },
        ),
    )
    end_date = forms.DateField(
        widget=DatePickerInput(
            attrs={"autocomplete": "off"},
            options={
                "useCurrent": False,
                "showTodayButton": False,
                "maxDate": yesterday.strftime("%Y-%m-%d"),
                "allowInputToggle": True,
            },
            range_from="start_date",
        ),
    )

Expected behavior
Both start_date and end_date should have a maxDate set before any dates are picked. However, only the end_date field has the maxDate set properly and start_date only reflects the date range correctly if end_date is picked first.

Screenshots
Start Date (today is Jan 24, 2025):
Image

Setup Information (please complete the following information):

  • OS: RHEL 9
  • Browser: Firefox
  • Browser version: 128.5.1esr (64-bit)
  • Python version: 3.11.10
  • Django version: 5.1.2
  • Bootstrap version: 4
  • jQuery version: 3.7.0

[x] I have followed the configuration instructions and checked out the
common error troubleshooting page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant