PHP
Joomla! 6
Joomla! 5
Joomla! 4
Template Override
Advanced
Render a Repeatable Subform Custom Field in Overrides
Iterates over $field->subform_rows on a Joomla Subform Custom Field to build FAQs, spec tables or feature grids.
templates/seu_template/html/com_content/article/default.php
<?php
declare(strict_types=1);
$fieldsByName = [];
foreach (($this->item->jcfields ?? []) as $f) {
$fieldsByName[$f->name] = $f;
}
$faqField = $fieldsByName['itens-faq'] ?? null;
if ($faqField && !empty($faqField->subform_rows)) : ?>
<dl class="pm-faq-list">
<?php foreach ($faqField->subform_rows as $row) : ?>
<dt><?php echo htmlspecialchars((string) ($row['pergunta']->rawvalue ?? ''), ENT_QUOTES, 'UTF-8'); ?></dt>
<dd><?php echo (string) ($row['resposta']->value ?? ''); ?></dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
Uses native $field->subform_rows with pre-rendered subfield values.
Technical explanation and best practices
Joomla 4, 5 and 6 subform custom fields expose $field->subform_rows with every nested subfield already prepared and keyed by machine name, eliminating manual JSON parsing.