[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/fields/checkboxes/ -> checkboxes.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Fields.Checkboxes
   6   *
   7   * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9  
  10   * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
  11   */
  12  
  13  // phpcs:disable PSR1.Files.SideEffects
  14  \defined('_JEXEC') or die;
  15  // phpcs:enable PSR1.Files.SideEffects
  16  
  17  /**
  18   * Fields Checkboxes Plugin
  19   *
  20   * @since  3.7.0
  21   */
  22  class PlgFieldsCheckboxes extends \Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin
  23  {
  24      /**
  25       * Before prepares the field value.
  26       *
  27       * @param   string     $context  The context.
  28       * @param   \stdclass  $item     The item.
  29       * @param   \stdclass  $field    The field.
  30       *
  31       * @return  void
  32       *
  33       * @since   3.7.0
  34       */
  35      public function onCustomFieldsBeforePrepareField($context, $item, $field)
  36      {
  37          if (!$this->app->isClient('api')) {
  38              return;
  39          }
  40  
  41          if (!$this->isTypeSupported($field->type)) {
  42              return;
  43          }
  44  
  45          $field->apivalue = [];
  46  
  47          $options = $this->getOptionsFromField($field);
  48  
  49          if (empty($field->value)) {
  50              return;
  51          }
  52  
  53          if (is_array($field->value)) {
  54              foreach ($field->value as $key => $value) {
  55                  $field->apivalue[$value] = $options[$value];
  56              }
  57          } else {
  58              $field->apivalue[$field->value] = $options[$field->value];
  59          }
  60      }
  61  }


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