Skip to content

Commit

Permalink
Fix an error for form usage, when dealing with nested entries
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Nov 14, 2024
1 parent 53b2c79 commit f717b7b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/templates/forms/_panes/usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@
{% set showDrafts = options.showDrafts ?? false %}
{% set showRevisions = options.showRevisions ?? false %}

{% set isValidElement = true %}
{% set render = true %}
{% set render = not showDrafts and element.isDraft() ? false : render %}
{% set render = not showRevisions and element.isRevision() ? false : render %}

{% if element is instance of('craft\\elements\\MatrixBlock') or element is instance of('verbb\\supertable\\elements\\SuperTableBlockElement') or element is instance of('benf\\neo\\elements\\Block') %}
{% if element is instance of('craft\\elements\\Entry') or element is instance of('benf\\neo\\elements\\Block') %}
{# Add a check here to ensure there's a valid owner (`getOwner()` will throw a hard-error) #}
{% set owner = craft.app.getElements().getElementById(element.ownerId, null, element.siteId) %}
{% set owner = craft.app.getElements().getElementById(element.ownerId, className(element), element.siteId) %}
{% set ownerField = craft.app.getFields().getFieldById(element.fieldId) %}

{% if owner %}
{{ _self.tableColumns(owner, ownerField, options) }}

{% set class = 'owner-row' %}
{% else %}
{% set render = false %}
{% set isValidElement = false %}
{% endif %}
{% endif %}

{% if render %}
<tr class="{{ class }}">
<th>
{{ elementChip(element, {
single: true,
}) }}
{% if isValidElement %}
{{ elementChip(element, {
single: true,
}) }}
{% else %}
{{ 'Invalid element #{element}' | t('formie', { element: element.id }) }}
{% endif %}
</th>

<td>{{ element.displayName() }}</td>
Expand Down

0 comments on commit f717b7b

Please sign in to comment.