<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
</tbody>
</table>
<p dir="auto">if there is child with name parent and I want to know if FormView has parent FormView, then it is impossible to find it</p>
<p dir="auto">FormView should have new method isParent</p>
<p dir="auto">How can know if a form has a parent or not, in a view?</p>
<p dir="auto">The fast answer is:</p>
<div class="highlight highlight-text-html-twig notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{{ form.parent }}"><pre class="notranslate">{{ <span class="pl-smi">form</span>.<span class="pl-smi">parent</span> }}</pre></div>
<p dir="auto">but if the form has a child called <code class="notranslate">parent</code> the above statement always return a result, even when they do not have a real parent.</p>
<p dir="auto">then the only way to know if has a real parent is something like:</p>
<div class="highlight highlight-text-html-twig notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{% set hasParent = (form.parent is not null and (not form.offsetExists('parent') or form.parent != form.offsetGet('parent'))) %}"><pre class="notranslate">{% <span class="pl-k">set</span> <span class="pl-smi">hasParent</span> <span class="pl-k">=</span> (<span class="pl-smi">form</span>.<span class="pl-smi">parent</span> <span class="pl-k">is not</span> <span class="pl-c1">null</span> <span class="pl-k">and</span> (<span class="pl-smi">not</span> form.<span class="pl-smi">offsetExists</span>(<span class="pl-s"><span class="pl-pds">'</span>parent<span class="pl-pds">'</span></span>) <span class="pl-k">or</span> <span class="pl-smi">form</span>.<span class="pl-smi">parent</span> <span class="pl-k">!=</span> form.<span class="pl-smi">offsetGet</span>(<span class="pl-s"><span class="pl-pds">'</span>parent<span class="pl-pds">'</span></span>))) %}</pre></div>
<p dir="auto">I'm missing something?</p>
<p dir="auto">a method <code class="notranslate">hasParent()</code> is needed in the FormView to avoid the \ArrayAccess.</p>