2

I have a Grid field (called 'beneficiaries') that I'm using to hold a list of first names and last names of beneficiaries, but I'm struggling to get a template to output the total number of rows my Grid field's currently holding. I'm able to output the entire field with the currently submitted data, using:

{exp:channel:form channel="beneficiary" return="/next_page" entry_id="8"}
    {beneficiaries}
{/exp:channel:form}

And that works great.

Now I just want to print to the screen the total number of rows, much like:

{exp:channel:form channel="beneficiary" return="/next_page" entry_id="8"}
    Total: {beneficiaries:total_rows}<br />
    Total: {beneficiaries:field_total_rows}<br />
    Total: {field:beneficiaries:total_rows}<br />
    Total: {field:beneficiaries:field_total_rows}<br />
{/exp:channel:form}

Which only returns the following:

Total: {beneficiaries:total_rows}
Total: {beneficiaries:field_total_rows}
Total:
Total:

Am I doing something painfully obviously wrong? I've read and re-read the documentation to no avail, and I have no idea what I could be doing wrong. Any help as to why I can't seem to display the row count would be greatly appreciated.

5

The grid field is a looping field, so if the field is in fact called beneficiaries, you should have:

{beneficiaries}
  {beneficiaries:total_rows}
  {beneficiaries:field_total_rows}
{/beneficiaries}
| improve this answer | |
  • ellislab.com/expressionengine/user-guide/add-ons/channel/… You can find the total rows outside the looping pair – Johnathan Waters Mar 24 '14 at 16:05
  • I hadn't realized that. Is that be the case within a channel form too? – Jean St-Amand Mar 24 '14 at 17:52
  • @JohnathanWaters - I've tried that with no success unfortunately :( See my OP...unless I've missed something? – Chris Kempen Mar 25 '14 at 9:03
  • @JeanSt-Amand Thanks for this! I would've liked to get this outside of the looping pair as it would be convenient to display other content depending on how many rows have been added...sigh! – Chris Kempen Mar 25 '14 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.