[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Form/Field/ -> ComboField.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Form\Field;
  11  
  12  // phpcs:disable PSR1.Files.SideEffects
  13  \defined('JPATH_PLATFORM') or die;
  14  // phpcs:enable PSR1.Files.SideEffects
  15  
  16  /**
  17   * Form Field class for the Joomla Platform.
  18   * Implements a combo box field.
  19   *
  20   * @since  1.7.0
  21   */
  22  class ComboField extends ListField
  23  {
  24      /**
  25       * The form field type.
  26       *
  27       * @var    string
  28       * @since  1.7.0
  29       */
  30      protected $type = 'Combo';
  31  
  32      /**
  33       * Name of the layout being used to render the field
  34       *
  35       * @var    string
  36       * @since  3.8.0
  37       */
  38      protected $layout = 'joomla.form.field.combo';
  39  
  40      /**
  41       * Method to get the field input markup for a combo box field.
  42       *
  43       * @return  string  The field input markup.
  44       *
  45       * @since   1.7.0
  46       */
  47      protected function getInput()
  48      {
  49          if (empty($this->layout)) {
  50              throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
  51          }
  52  
  53          return $this->getRenderer($this->layout)->render($this->getLayoutData());
  54      }
  55  
  56      /**
  57       * Method to get the data to be passed to the layout for rendering.
  58       *
  59       * @return  array
  60       *
  61       * @since   3.8.0
  62       */
  63      protected function getLayoutData()
  64      {
  65          $data = parent::getLayoutData();
  66  
  67          // Get the field options.
  68          $options = $this->getOptions();
  69  
  70          $extraData = array(
  71              'options' => $options,
  72          );
  73  
  74          return array_merge($data, $extraData);
  75      }
  76  }


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