[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_fields/src/Field/ -> SectionField.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_fields
   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  namespace Joomla\Component\Fields\Administrator\Field;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Form\Field\ListField;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Fields Section
  22   *
  23   * @since  3.7.0
  24   */
  25  class SectionField extends ListField
  26  {
  27      /**
  28       * Type of the field
  29       *
  30       * @var    string
  31       */
  32      public $type = 'Section';
  33  
  34      /**
  35       * Method to attach a JForm object to the field.
  36       *
  37       * @param   \SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
  38       * @param   mixed              $value    The form field value to validate.
  39       * @param   string             $group    The field name group control value. This acts as an array container for the field.
  40       *                                       For example if the field has name="foo" and the group value is set to "bar" then the
  41       *                                       full field name would end up being "bar[foo]".
  42       *
  43       * @return  boolean  True on success.
  44       *
  45       * @since   3.7.0
  46       */
  47      public function setup(\SimpleXMLElement $element, $value, $group = null)
  48      {
  49          $return = parent::setup($element, $value, $group);
  50  
  51          // Onchange must always be the change context function
  52          $this->onchange = 'Joomla.fieldsChangeContext(this.value);';
  53  
  54          return $return;
  55      }
  56  
  57      /**
  58       * Method to get the field input markup for a generic list.
  59       * Use the multiple attribute to enable multiselect.
  60       *
  61       * @return  string  The field input markup.
  62       *
  63       * @since   3.7.0
  64       */
  65      protected function getInput()
  66      {
  67          Factory::getApplication()->getDocument()->getWebAssetManager()
  68              ->useScript('com_fields.admin-field-changecontext');
  69  
  70          return parent::getInput();
  71      }
  72  }


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