New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Is it possible to use first row table headers as data attributes?

Andrew Larner May 18, 2021 by Andrew Larner

Hi,

I'm using a table field, as per the docs, with a first_row_headers toggle. I was wondering if it is possible to loop those first row headers over my td tags as data attributes. The aim is to be able to break the table rows into blocks on mobile, showing data attributes with my header content on the tds.

I can't figure out how to achieve this, below is how it should output for each tr:

<tr>
  <td data-title="[ first row header title one here ]">{{ value|markdown }}</td>
  <td data-title="[ first row header title two here ]">{{ value|markdown }}</td>
  <td data-title="[ first row header title three here ]">{{ value|markdown }}</td>
  <td data-title="[ first row header title four here ]">{{ value|markdown }}</td>
  <td data-title="[ first row header title five here ]">{{ value|markdown }}</td>
</tr>


Thanks for any help!

Answered by Johnathon Koster!
>>>>>>> Answered <<<<<<<
2 Replies
2 Followers