Answers.Body: <p>This is a weird twig behavior. You have to do <code>if   stRow['caption'] is defined</code> to make it work because of the object syntax of twig.</p>
  
  <p>Sometimes the if defined statement becomes true when you don't use the array syntax </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-03T22:29:14.610Z
Answers.Text: Huh... weird. That totally fixed it. Thanks Robin! That's a fairly specific little piece of knowledge that should probably be really up front in the docs. Thanks for your help.
Answers.UserDisplayName: JamesNZ
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-30T04:49:19.567Z
Answers.LastActivityDate: 2017-11-30T04:49:19.567Z
Answers.UserDisplayName: Robin Schambach
Body: <p>Why is it that in the below, referencing stRow.caption causes an error despite being wrapped in an "if defined" check?</p>
  
  <p>The error is: </p>
  
  <blockquote>
    <p>Craft\SuperTable_BlockModel and its behaviors do not have a method or
    closure named "caption".</p>
  </blockquote>
  
  <p>I have to be doing something so catastrophically dumb that it's not sticking out yeah?</p>
  
  <hr>
  
  <pre><code>{% if stRow.caption is defined %}
      {% set caption = stRow.caption %} &lt;&lt;- This line causes the error
  {% endif %}
  </code></pre>
  
  <p>Same with using a null coelescing operator or a ternary operand.</p>
  
  <pre><code>{{ stRow.caption ?? "" }} &lt;&lt;- This causes the error
  -- or --
  {{ stRow.caption is defined ? stRow.caption : "" }}  &lt;&lt;- This causes the error too!
  </code></pre>
  
  <p>All three of those should work.</p>
  
  <p>Supertable: 1.0.4
  Craft CMS: 2.6.2997</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-30T03:03:31.113Z
Comments.Text: Did you try `| length` ?
Comments.UserDisplayName: hashtagerrors
Tags: <templating><conditional><plugin-supertable><defined>
Title: Is defined conditional passing, yet causes a "do not have a method or closure named" error
ThreadText: # Is defined conditional passing, yet causes a "do not have a method or closure named" error
  
  (Asked by: username_0 on 2017-11-30)
  
  Why is it that in the below, referencing stRow.caption causes an error despite being wrapped in an "if defined" check?
  
  The error is:
  
  > Craft\SuperTable\_BlockModel and its behaviors do not have a method or
  > closure named "caption".
  
  I have to be doing something so catastrophically dumb that it's not sticking out yeah?
  
  ---
  
  ```
  {% if stRow.caption is defined %}
      {% set caption = stRow.caption %} <<- This line causes the error
  {% endif %}
  
  ```
  
  Same with using a null coelescing operator or a ternary operand.
  
  ```
  {{ stRow.caption ?? "" }} <<- This causes the error
  -- or --
  {{ stRow.caption is defined ? stRow.caption : "" }}  <<- This causes the error too!
  
  ```
  
  All three of those should work.
  
  Supertable: 1.0.4
  Craft CMS: 2.6.2997
  
  **Tags:** templating, conditional, plugin-supertable, defined
  
  > **Comments:**
  > **username_1**: Did you try `| length` ?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-11-30. Score: 2 | Accepted answer
  
  This is a weird twig behavior. You have to do `if stRow['caption'] is defined` to make it work because of the object syntax of twig.
  
  Sometimes the if defined statement becomes true when you don't use the array syntax
  
  > **Comments:**
  > **username_0**: Huh... weird. That totally fixed it. Thanks username_2! That's a fairly specific little piece of knowledge that should probably be really up front in the docs. Thanks for your help.  
  
  ---
  
  