How can I tell if a field exists in a block of a matrix? I want to see if a certain field exists in a block of a matrix. Here is my code.

{% for block in entry.someStepContainer %}
  &lt;div class="each-step"&gt;

    {% if block.type == "someStep" %}
      &lt;div class="step-number"&gt;&lt;span&gt;{{loop.index}}&lt;/span&gt;&lt;/div&gt;
      &lt;h3 class="step-title"&gt;{{block.stepTitle}}&lt;/h3&gt;
      &lt;div class="step-description"&gt;{{block.stepDescription}}&lt;/div&gt;

      &lt;! -- this is part I'm trying to fix --&gt;

      {% if block.stepAccordionContent %}
        &lt;div class="accordion-section"&gt;
          {% for row in block.stepAccordionContent %}
            &lt;h3 class="accordion-control"&gt;{{row.accordionTitle}}&lt;/h3&gt;
            &lt;p class="accordion-content" style="display: none;"&gt;{{row.accordionContent}}&lt;/p&gt;
          {% endfor %}
        &lt;/div&gt;
      {% endif %}


      &lt;!-- end part --&gt;

    {% endif %}

  &lt;/div&gt;
{% endfor %} 


I've tried using:

{% if block.stepAccordionContent | length %}


But this still yields an empty

&lt;div class="accordion-section"&gt;


stepAccordionContent is a table.
You can use {% if block.stepAccordionContent|length  %}...{% endif %} to test if any rows are defined in your table field.

Note: When you create a table field it will have an empty row defined under 'Default Values', which should be removed; otherwise all new instances of the table will have an empty row defined by default causing block.stepAccordionContent|length to return 1, instead of 0 as expected.