CoreFiles by mySites.guru
subform.php60 lines, 1,571 bytes, from Joomla_4.3.3-Stable-Full_Package.zip
Raw History Compare with 4.3.2
md5
13e0c0136ac8fa7a7104ff62dcd96a3b
sha1
bc0aac8ac0298fad3b3647102a95debc526fef1b
sha256
4c6622a25c3a264dbe90ae8854b083cecbcae20a1a6183c4bde95e97fa4cbb1e
<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Subform
 *
 * @copyright   (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

defined('_JEXEC') or die;

if (!$context || empty($field->subform_rows)) {
    return;
}

$result = '';

// Iterate over each row that we have
foreach ($field->subform_rows as $subform_row) {
    // Placeholder array to generate this rows output
    $row_output = [];

    // Iterate over each sub field inside of that row
    foreach ($subform_row as $subfield) {
        $class   = trim($subfield->params->get('render_class', ''));
        $layout  = trim($subfield->params->get('layout', 'render'));
        $content = trim(
            FieldsHelper::render(
                $context,
                'field.' . $layout, // normally just 'field.render'
                ['field' => $subfield]
            )
        );

        // Skip empty output
        if ($content === '') {
            continue;
        }

        // Generate the output for this sub field and row
        $row_output[] = '<span class="field-entry' . ($class ? (' ' . $class) : '') . '">' . $content . '</span>';
    }

    // Skip empty rows
    if (count($row_output) == 0) {
        continue;
    }

    $result .= '<li>' . implode(', ', $row_output) . '</li>';
}
?>

<?php if (trim($result) != '') : ?>
    <ul class="fields-container">
        <?php echo $result; ?>
    </ul>
<?php endif; ?>

The same content is in 214 releases, Joomla 4.2.7-rc1 to 6.2.1-rc1. See them all, or every version of this file.