Jump to content

Custom date search filters don't persist form value through refresh

Go to solution Solved by Marc Stridgen,

Recommended Posts

To reproduce:

  • Go to the full search page, /search/
  • Apply a date filter (either created or updated), with value set to "Custom" and a start and/or end date
    Could contain: Page, Text, File
  • Enter a search term, and submit
  • Refresh the page (or click one of the "Didn't find what you were looking for" suggested filters)
  • Expand the search filter options again, and observe that the supplied date filter has been cleared
    Could contain: Page, Text, File, Invoice, Document
  • Edit the search term, then submit the search request again, and observe that the date filter is no longer being applied

This is because in core/html/front/search/filters.phtml, lines 193/197/219/223, you're directly stringifying the current value, which is a \IPS\DateTime


which results in a non-ISO8601-compliant timestamp like "11/03/22 12:00  AM" (rather than 2022-11-03). You probably need to do something like you already have in the regular Date form element template

value="{{if $value instanceof \IPS\DateTime}}{$value->format('Y-m-d')}{{else}}{$value}{{endif}}"


(This was reported to me by a user using Firefox, and reproed also in Firefox. It's possible that other browsers tolerate the invalid values, I haven't checked, but doing so would not be standards compliant).

Edited by Colonel_mortis
Link to comment
Share on other sites

  • 4 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...