Sorting events with acf_date

Hey!

I want to sort my events by date using <Table>.
Everything is fine with <input type=text>, but with <input type=date>, search is not working, and returns “Empty”

<Table sort="acf_date=date" sort_order=asc>

  <Filter>
    <div>
      <input type="date"  action="search"  columns="acf_date=date">
    </div>
  </Filter>

  <Head>
    <Col name=title sort_type=string>Title</Col>
    <Col name="acf_date=date" sort_type="date">Date</Col>
  </Head>

  <RowLoop type=event_calendar>
    <Col>
      <Field title />
    </Col>
    <Col>
      <Field acf_date=date />
    </Col>
  </RowLoop>

  <Empty>
    <p>Empty</p>
  </Empty>
  
</Table>

I also tried to search by poost date. That didn’t worked as well. So I guess there is something wrong with input?

It could be that in the context of table filtering, the input tag only accepts type="text". I haven’t experimented much with the Table tag myself, but I know that the reason it’s not more broadly documented is that it was created for a specific use-case when displaying Gravity Forms data and it’s going to be rewritten in the future to make it much more flexible. I wouldn’t be surprised if this is simply a limitation of the current implementation of the Table tag. When I look at the docs for the table tag, I’m noticing that all the table columns—even the ones that have dates in them—are set up with sort_type=string, which further suggests that the current implementation of the Table tag only allows filtering with strings. I may very well be wrong and @eliot would be the one who could clarify this, but I thought I’d share my hypothesis about why this might be happening in your case. Sorry that I don’t have a more definitive answer!

@benjamin See this topic for more info on sorting by date.
As for filtering, we’ll need to dig a little deeper. It could be an issue with date formatting, which tends to need to be defined for this sort of thing to work

1 Like