Skip to content

Instantly share code, notes, and snippets.

@ademers
Last active September 29, 2021 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ademers/f207b3a62423f62142568e53a941275b to your computer and use it in GitHub Desktop.
Save ademers/f207b3a62423f62142568e53a941275b to your computer and use it in GitHub Desktop.
{# NOTE: Required so that judges don't override other judges' matrix blocks! #}
<!-- Matrix blocks exist -->
{% if entry.judgeSelections|length %}
{% for block in entry.judgeSelections.all() %}
<input type="hidden"
name="fields[judgeSelections][{{ block.id }}][type]"
value="judgeSelection"
>
<input type="hidden"
name="fields[judgeSelections][{{ block.id }}][enabled]"
value="1"
>
{% endfor %}
{# If not Matrix blocks, add new one for current user #}
{% else %}
<input type="hidden"
name="fields[judgeSelections][new1][type]"
value="judgeSelection"
>
<input type="hidden"
name="fields[judgeSelections][new1][enabled]"
value="1"
>
<input type="hidden"
name="fields[judgeSelections][new1][fields][member][user.id]"
value="{{ currentUser.id }}"
>
<input type="hidden"
name="fields[judgeSelections][new1][fields][memberId]"
value="{{ currentUser.id }}"
>
{% endif %}
<!-- /Matrix blocks exist -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment