[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/fields/subform/tmpl/ -> subform.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Fields.Subform
   6   *
   7   * @copyright   (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
  12  
  13  defined('_JEXEC') or die;
  14  
  15  if (!$context || empty($field->subform_rows)) {
  16      return;
  17  }
  18  
  19  $result = '';
  20  
  21  // Iterate over each row that we have
  22  foreach ($field->subform_rows as $subform_row) {
  23      // Placeholder array to generate this rows output
  24      $row_output = array();
  25  
  26      // Iterate over each sub field inside of that row
  27      foreach ($subform_row as $subfield) {
  28          $class   = trim($subfield->params->get('render_class', ''));
  29          $layout  = trim($subfield->params->get('layout', 'render'));
  30          $content = trim(
  31              FieldsHelper::render(
  32                  $context,
  33                  'field.' . $layout, // normally just 'field.render'
  34                  array('field' => $subfield)
  35              )
  36          );
  37  
  38          // Skip empty output
  39          if ($content === '') {
  40              continue;
  41          }
  42  
  43          // Generate the output for this sub field and row
  44          $row_output[] = '<span class="field-entry' . ($class ? (' ' . $class) : '') . '">' . $content . '</span>';
  45      }
  46  
  47      // Skip empty rows
  48      if (count($row_output) == 0) {
  49          continue;
  50      }
  51  
  52      $result .= '<li>' . implode(', ', $row_output) . '</li>';
  53  }
  54  ?>
  55  
  56  <?php if (trim($result) != '') : ?>
  57      <ul class="fields-container">
  58          <?php echo $result; ?>
  59      </ul>
  60  <?php endif; ?>


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer