[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/layouts/joomla/form/field/subform/ -> repeatable-table.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Layout
   6   *
   7   * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Form\Form;
  15  use Joomla\CMS\Language\Text;
  16  
  17  extract($displayData);
  18  
  19  /**
  20   * Layout variables
  21   * -----------------
  22   * @var   Form    $tmpl             The Empty form for template
  23   * @var   array   $forms            Array of JForm instances for render the rows
  24   * @var   bool    $multiple         The multiple state for the form field
  25   * @var   int     $min              Count of minimum repeating in multiple mode
  26   * @var   int     $max              Count of maximum repeating in multiple mode
  27   * @var   string  $name             Name of the input field.
  28   * @var   string  $fieldname        The field name
  29   * @var   string  $fieldId          The field ID
  30   * @var   string  $control          The forms control
  31   * @var   string  $label            The field label
  32   * @var   string  $description      The field description
  33   * @var   string  $class            Classes for the container
  34   * @var   array   $buttons          Array of the buttons that will be rendered
  35   * @var   bool    $groupByFieldset  Whether group the subform fields by it`s fieldset
  36   */
  37  if ($multiple) {
  38      // Add script
  39      Factory::getApplication()
  40          ->getDocument()
  41          ->getWebAssetManager()
  42          ->useScript('webcomponent.field-subform');
  43  }
  44  
  45  $class = $class ? ' ' . $class : '';
  46  
  47  // Build heading
  48  $table_head = '';
  49  
  50  if (!empty($groupByFieldset)) {
  51      foreach ($tmpl->getFieldsets() as $fieldset) {
  52          $table_head .= '<th scope="col">' . Text::_($fieldset->label);
  53  
  54          if ($fieldset->description) {
  55              $table_head .= '<span class="icon-info-circle" aria-hidden="true" tabindex="0"></span><div role="tooltip" id="tip-' . $field->id . '">' . Text::_($field->description) . '</div>';
  56          }
  57  
  58          $table_head .= '</th>';
  59      }
  60  
  61      $sublayout = 'section-byfieldsets';
  62  } else {
  63      foreach ($tmpl->getGroup('') as $field) {
  64          $table_head .= '<th scope="col" style="width:45%">' . strip_tags($field->label);
  65  
  66          if ($field->description) {
  67              $table_head .= '<span class="icon-info-circle" aria-hidden="true" tabindex="0"></span><div role="tooltip" id="tip-' . $field->id . '">' . Text::_($field->description) . '</div>';
  68          }
  69  
  70          $table_head .= '</th>';
  71      }
  72  
  73      $sublayout = 'section';
  74  
  75      // Label will not be shown for sections layout, so reset the margin left
  76      Factory::getApplication()
  77          ->getDocument()
  78          ->addStyleDeclaration('.subform-table-sublayout-section .controls { margin-left: 0px }');
  79  }
  80  ?>
  81  
  82  <div class="subform-repeatable-wrapper subform-table-layout subform-table-sublayout-<?php echo $sublayout; ?>">
  83      <joomla-field-subform class="subform-repeatable<?php echo $class; ?>" name="<?php echo $name; ?>"
  84          button-add=".group-add" button-remove=".group-remove" button-move="<?php echo empty($buttons['move']) ? '' : '.group-move' ?>"
  85          repeatable-element=".subform-repeatable-group"
  86          rows-container="tbody.subform-repeatable-container" minimum="<?php echo $min; ?>" maximum="<?php echo $max; ?>">
  87          <div class="table-responsive">
  88              <table class="table" id="subfieldList_<?php echo $fieldId; ?>">
  89                  <caption class="visually-hidden">
  90                      <?php echo Text::_('JGLOBAL_REPEATABLE_FIELDS_TABLE_CAPTION'); ?>
  91                  </caption>
  92                  <thead>
  93                      <tr>
  94                          <?php echo $table_head; ?>
  95                          <?php if (!empty($buttons)) : ?>
  96                          <td style="width:8%;">
  97                              <?php if (!empty($buttons['add'])) : ?>
  98                                  <div class="btn-group">
  99                                      <button type="button" class="group-add btn btn-sm btn-success" aria-label="<?php echo Text::_('JGLOBAL_FIELD_ADD'); ?>">
 100                                          <span class="icon-plus" aria-hidden="true"></span>
 101                                      </button>
 102                                  </div>
 103                              <?php endif; ?>
 104                          </td>
 105                          <?php endif; ?>
 106                      </tr>
 107                  </thead>
 108                  <tbody class="subform-repeatable-container">
 109                  <?php
 110                  foreach ($forms as $k => $form) :
 111                      echo $this->sublayout($sublayout, array('form' => $form, 'basegroup' => $fieldname, 'group' => $fieldname . $k, 'buttons' => $buttons));
 112                  endforeach;
 113                  ?>
 114                  </tbody>
 115              </table>
 116          </div>
 117          <?php if ($multiple) : ?>
 118          <template class="subform-repeatable-template-section hidden">
 119              <?php echo trim($this->sublayout($sublayout, array('form' => $tmpl, 'basegroup' => $fieldname, 'group' => $fieldname . 'X', 'buttons' => $buttons))); ?>
 120          </template>
 121          <?php endif; ?>
 122      </joomla-field-subform>
 123  </div>


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