<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>2.7</td>
</tr>
</tbody>
</table>
<p dir="auto">Hi there!</p>
<p dir="auto">This morning I faced <a href="https://github.com/javiereguiluz/EasyAdminBundle/issues/1913">an issue</a> in EasyAdminBundle related to form themes and <code class="notranslate">form.parent</code> check in Twig.</p>
<p dir="auto">Briefly, the problem happen if we have a simple form with a field named <code class="notranslate">parent</code>. The situation gets worse depending on whether the <code class="notranslate">parent</code> field has children or not.</p>
<p dir="auto">First, let's see the <code class="notranslate">FormView</code> class, especially the <code class="notranslate">parent</code> property and <code class="notranslate">\ArrayAccess</code> methods:<br>
</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/symfony/symfony/blob/61b753443d6903d8a9644f62caf020fdfca3ef6f/src/Symfony/Component/Form/FormView.php#L19-L126">symfony/src/Symfony/Component/Form/FormView.php</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 19 to 126
      in
      <a data-pjax="true" class="commit-tease-sha" href="/symfony/symfony/commit/61b753443d6903d8a9644f62caf020fdfca3ef6f">61b7534</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L19" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="19"></td>
          <td id="LC19" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">class</span> <span class="pl-v">FormView</span> <span class="pl-k">implements</span> \<span class="pl-v">ArrayAccess</span>, \<span class="pl-v">IteratorAggregate</span>, \<span class="pl-v">Countable</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L20" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="20"></td>
          <td id="LC20" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> { </td>
        </tr>

        <tr class="border-0">
          <td id="L21" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="21"></td>
          <td id="LC21" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L22" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="22"></td>
          <td id="LC22" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * The variables assigned to this view.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L23" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="23"></td>
          <td id="LC23" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L24" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="24"></td>
          <td id="LC24" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-c1"><span class="pl-c1">$</span>vars</span> = <span class="pl-en">array</span>( </td>
        </tr>

        <tr class="border-0">
          <td id="L25" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="25"></td>
          <td id="LC25" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s">'value'</span> =&gt; <span class="pl-c1">null</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L26" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="26"></td>
          <td id="LC26" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s">'attr'</span> =&gt; <span class="pl-en">array</span>(), </td>
        </tr>

        <tr class="border-0">
          <td id="L27" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="27"></td>
          <td id="LC27" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     ); </td>
        </tr>

        <tr class="border-0">
          <td id="L28" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="28"></td>
          <td id="LC28" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L29" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="29"></td>
          <td id="LC29" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L30" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="30"></td>
          <td id="LC30" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * The parent view.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L31" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="31"></td>
          <td id="LC31" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L32" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="32"></td>
          <td id="LC32" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-c1"><span class="pl-c1">$</span>parent</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L33" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="33"></td>
          <td id="LC33" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L34" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="34"></td>
          <td id="LC34" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L35" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="35"></td>
          <td id="LC35" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * The child views.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L36" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="36"></td>
          <td id="LC36" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L37" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="37"></td>
          <td id="LC37" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @var FormView[]</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L38" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="38"></td>
          <td id="LC38" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L39" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="39"></td>
          <td id="LC39" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-c1"><span class="pl-c1">$</span>children</span> = <span class="pl-en">array</span>(); </td>
        </tr>

        <tr class="border-0">
          <td id="L40" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="40"></td>
          <td id="LC40" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L41" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="41"></td>
          <td id="LC41" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L42" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="42"></td>
          <td id="LC42" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * Is the form attached to this renderer rendered?</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L43" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="43"></td>
          <td id="LC43" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L44" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="44"></td>
          <td id="LC44" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * Rendering happens when either the widget or the row method was called.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L45" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="45"></td>
          <td id="LC45" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * Row implicitly includes widget, however certain rendering mechanisms</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L46" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="46"></td>
          <td id="LC46" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * have to skip widget rendering when a row is rendered.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L47" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="47"></td>
          <td id="LC47" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L48" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="48"></td>
          <td id="LC48" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @var bool</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L49" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="49"></td>
          <td id="LC49" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L50" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="50"></td>
          <td id="LC50" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">private</span> <span class="pl-c1"><span class="pl-c1">$</span>rendered</span> = <span class="pl-c1">false</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L51" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="51"></td>
          <td id="LC51" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L52" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="52"></td>
          <td id="LC52" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">private</span> <span class="pl-c1"><span class="pl-c1">$</span>methodRendered</span> = <span class="pl-c1">false</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L53" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="53"></td>
          <td id="LC53" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L54" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="54"></td>
          <td id="LC54" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">__construct</span>(<span class="pl-smi"><span class="pl-smi">FormView</span></span> <span class="pl-s1"><span class="pl-c1">$</span>parent</span> = <span class="pl-c1">null</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L55" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="55"></td>
          <td id="LC55" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L56" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="56"></td>
          <td id="LC56" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">parent</span> = <span class="pl-s1"><span class="pl-c1">$</span>parent</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L57" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="57"></td>
          <td id="LC57" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L58" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="58"></td>
          <td id="LC58" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L59" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="59"></td>
          <td id="LC59" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L60" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="60"></td>
          <td id="LC60" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * Returns whether the view was already rendered.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L61" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="61"></td>
          <td id="LC61" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L62" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="62"></td>
          <td id="LC62" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @return bool Whether this view's widget is rendered</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L63" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="63"></td>
          <td id="LC63" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L64" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="64"></td>
          <td id="LC64" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">isRendered</span>() </td>
        </tr>

        <tr class="border-0">
          <td id="L65" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="65"></td>
          <td id="LC65" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L66" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="66"></td>
          <td id="LC66" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">if</span> (<span class="pl-c1">true</span> === <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">rendered</span> || <span class="pl-c1">0</span> === count(<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">children</span>)) { </td>
        </tr>

        <tr class="border-0">
          <td id="L67" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="67"></td>
          <td id="LC67" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">             <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">rendered</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L68" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="68"></td>
          <td id="LC68" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         } </td>
        </tr>

        <tr class="border-0">
          <td id="L69" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="69"></td>
          <td id="LC69" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L70" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="70"></td>
          <td id="LC70" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">foreach</span> (<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">children</span> <span class="pl-k">as</span> <span class="pl-s1"><span class="pl-c1">$</span>child</span>) { </td>
        </tr>

        <tr class="border-0">
          <td id="L71" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="71"></td>
          <td id="LC71" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">             <span class="pl-k">if</span> (!<span class="pl-s1"><span class="pl-c1">$</span>child</span>-&gt;<span class="pl-en">isRendered</span>()) { </td>
        </tr>

        <tr class="border-0">
          <td id="L72" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="72"></td>
          <td id="LC72" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">                 <span class="pl-k">return</span> <span class="pl-c1">false</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L73" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="73"></td>
          <td id="LC73" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">             } </td>
        </tr>

        <tr class="border-0">
          <td id="L74" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="74"></td>
          <td id="LC74" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         } </td>
        </tr>

        <tr class="border-0">
          <td id="L75" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="75"></td>
          <td id="LC75" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L76" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="76"></td>
          <td id="LC76" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">rendered</span> = <span class="pl-c1">true</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L77" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="77"></td>
          <td id="LC77" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L78" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="78"></td>
          <td id="LC78" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L79" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="79"></td>
          <td id="LC79" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L80" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="80"></td>
          <td id="LC80" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * Marks the view as rendered.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L81" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="81"></td>
          <td id="LC81" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L82" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="82"></td>
          <td id="LC82" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @return $this</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L83" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="83"></td>
          <td id="LC83" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L84" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="84"></td>
          <td id="LC84" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">setRendered</span>() </td>
        </tr>

        <tr class="border-0">
          <td id="L85" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="85"></td>
          <td id="LC85" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L86" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="86"></td>
          <td id="LC86" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">rendered</span> = <span class="pl-c1">true</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L87" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="87"></td>
          <td id="LC87" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L88" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="88"></td>
          <td id="LC88" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L89" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="89"></td>
          <td id="LC89" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L90" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="90"></td>
          <td id="LC90" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L91" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="91"></td>
          <td id="LC91" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L92" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="92"></td>
          <td id="LC92" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @return bool</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L93" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="93"></td>
          <td id="LC93" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L94" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="94"></td>
          <td id="LC94" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">isMethodRendered</span>() </td>
        </tr>

        <tr class="border-0">
          <td id="L95" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="95"></td>
          <td id="LC95" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L96" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="96"></td>
          <td id="LC96" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">methodRendered</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L97" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="97"></td>
          <td id="LC97" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L98" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="98"></td>
          <td id="LC98" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L99" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="99"></td>
          <td id="LC99" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">setMethodRendered</span>() </td>
        </tr>

        <tr class="border-0">
          <td id="L100" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="100"></td>
          <td id="LC100" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L101" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="101"></td>
          <td id="LC101" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">methodRendered</span> = <span class="pl-c1">true</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L102" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="102"></td>
          <td id="LC102" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L103" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="103"></td>
          <td id="LC103" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L104" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="104"></td>
          <td id="LC104" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L105" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="105"></td>
          <td id="LC105" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * Returns a child by name (implements \ArrayAccess).</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L106" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="106"></td>
          <td id="LC106" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L107" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="107"></td>
          <td id="LC107" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @param string $name The child name</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L108" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="108"></td>
          <td id="LC108" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L109" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="109"></td>
          <td id="LC109" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @return self The child view</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L110" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="110"></td>
          <td id="LC110" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L111" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="111"></td>
          <td id="LC111" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">offsetGet</span>(<span class="pl-s1"><span class="pl-c1">$</span>name</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L112" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="112"></td>
          <td id="LC112" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L113" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="113"></td>
          <td id="LC113" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">children</span>[<span class="pl-s1"><span class="pl-c1">$</span>name</span>]; </td>
        </tr>

        <tr class="border-0">
          <td id="L114" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="114"></td>
          <td id="LC114" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L115" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="115"></td>
          <td id="LC115" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L116" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="116"></td>
          <td id="LC116" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c">/**</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L117" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="117"></td>
          <td id="LC117" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * Returns whether the given child exists (implements \ArrayAccess).</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L118" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="118"></td>
          <td id="LC118" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L119" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="119"></td>
          <td id="LC119" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @param string $name The child name</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L120" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="120"></td>
          <td id="LC120" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     *</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L121" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="121"></td>
          <td id="LC121" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     * @return bool Whether the child view exists</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L122" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="122"></td>
          <td id="LC122" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">     */</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L123" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="123"></td>
          <td id="LC123" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">offsetExists</span>(<span class="pl-s1"><span class="pl-c1">$</span>name</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L124" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="124"></td>
          <td id="LC124" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L125" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="125"></td>
          <td id="LC125" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">return</span> isset(<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">children</span>[<span class="pl-s1"><span class="pl-c1">$</span>name</span>]); </td>
        </tr>

        <tr class="border-0">
          <td id="L126" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="126"></td>
          <td id="LC126" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">In PHP context there's no problem, the main form view has the <code class="notranslate">$form-&gt;parent</code> property and its children's fields (<code class="notranslate">$form['parent']</code>), each one accessible unmistakably by syntax. <strong>But</strong>, in Twig context, this access/check <code class="notranslate">{% if form.parent is null/empty %}</code> causes a naming collision. The <code class="notranslate">parent</code> attribute is resolved by Twig following the steps below:</p>
<blockquote>
<p dir="auto"><a href="https://twig.symfony.com/doc/2.x/templates.html#variables" rel="nofollow">https://twig.symfony.com/doc/2.x/templates.html#variables</a><br>
For convenience's sake <code class="notranslate">form.parent</code> does the following things on the PHP layer:</p>
<ul dir="auto">
<li><a href="https://github.com/twigphp/Twig/blob/31b577863b5ae8d19e2cefd174e95a433f16491f/lib/Twig/Extension/Core.php#L1437-L1445">check if <code class="notranslate">form</code> is an array and <code class="notranslate">parent</code> a valid element;</a> &lt;-- always wins in this particular case</li>
<li>if not, and if <code class="notranslate">form</code> is an object, check that <code class="notranslate">parent</code> is a valid property; &lt;-- never reached</li>
<li>...</li>
<li>if not, and if <code class="notranslate">form</code> is an object, check that <code class="notranslate">getParent</code> is a valid method;</li>
</ul>
</blockquote>
<p dir="auto">Therefore, the <code class="notranslate">parent</code> child field view is returned instead of the real <code class="notranslate">parent</code> view (which is null in this case)!</p>
<p dir="auto">There's some place in the source where this kind of check is done and surely in many bundles and apps:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2028198/32636294-245a0ef6-c582-11e7-9ed7-0995f191c61d.png"><img src="https://user-images.githubusercontent.com/2028198/32636294-245a0ef6-c582-11e7-9ed7-0995f191c61d.png" alt="form_parent" style="max-width: 100%;"></a></p>
<p dir="auto">I'm not sure if there's a workaround for current projects/bundles rely on the Symfony form themes templates. I don't think it is a bug of Twig either, but a design error of the <code class="notranslate">FormView</code> class, which is specially designed to work in Twig context.</p>
<p dir="auto">We may need a getter method for this <code class="notranslate">parent</code> property by now and check <code class="notranslate">{% if form.getParent %}</code> everywhere avoiding the first rule. Wdyt? thoughts?</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>