[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/layouts/joomla/form/field/subform/ -> repeatable.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  $sublayout = empty($groupByFieldset) ? 'section' : 'section-byfieldsets';
  48  ?>
  49  
  50  <div class="subform-repeatable-wrapper subform-layout">
  51      <joomla-field-subform class="subform-repeatable<?php echo $class; ?>" name="<?php echo $name; ?>"
  52          button-add=".group-add" button-remove=".group-remove" button-move="<?php echo empty($buttons['move']) ? '' : '.group-move' ?>"
  53          repeatable-element=".subform-repeatable-group" minimum="<?php echo $min; ?>" maximum="<?php echo $max; ?>">
  54          <?php if (!empty($buttons['add'])) : ?>
  55          <div class="btn-toolbar">
  56              <div class="btn-group">
  57                  <button type="button" class="group-add btn btn-sm button btn-success" aria-label="<?php echo Text::_('JGLOBAL_FIELD_ADD'); ?>">
  58                      <span class="icon-plus icon-white" aria-hidden="true"></span>
  59                  </button>
  60              </div>
  61          </div>
  62          <?php endif; ?>
  63      <?php
  64      foreach ($forms as $k => $form) :
  65          echo $this->sublayout($sublayout, array('form' => $form, 'basegroup' => $fieldname, 'group' => $fieldname . $k, 'buttons' => $buttons));
  66      endforeach;
  67      ?>
  68      <?php if ($multiple) : ?>
  69      <template class="subform-repeatable-template-section hidden"><?php
  70          echo trim($this->sublayout($sublayout, array('form' => $tmpl, 'basegroup' => $fieldname, 'group' => $fieldname . 'X', 'buttons' => $buttons)));
  71      ?></template>
  72      <?php endif; ?>
  73      </joomla-field-subform>
  74  </div>


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