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.

1 Answer 1

6

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}
4
  • ellislab.com/expressionengine/user-guide/add-ons/channel/… You can find the total rows outside the looping pair Mar 24, 2014 at 16:05
  • I hadn't realized that. Is that be the case within a channel form too? Mar 24, 2014 at 17:52
  • @JohnathanWaters - I've tried that with no success unfortunately :( See my OP...unless I've missed something? Mar 25, 2014 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! Mar 25, 2014 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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