[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2013 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  use Joomla\CMS\Form\FormField;
  13  use Joomla\CMS\HTML\HTMLHelper;
  14  use Joomla\CMS\Language\Text;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('JPATH_PLATFORM') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Form Field class for the Joomla Platform.
  22   * Supports a one line text field.
  23   *
  24   * @link   https://html.spec.whatwg.org/multipage/input.html#text-(type=text)-state-and-search-state-(type=search)
  25   * @since  1.7.0
  26   */
  27  class NoteField extends FormField
  28  {
  29      /**
  30       * The form field type.
  31       *
  32       * @var    string
  33       * @since  1.7.0
  34       */
  35      protected $type = 'Note';
  36  
  37      /**
  38       * Hide the label when rendering the form field.
  39       *
  40       * @var    boolean
  41       * @since  4.0.0
  42       */
  43      protected $hiddenLabel = true;
  44  
  45      /**
  46       * Hide the description when rendering the form field.
  47       *
  48       * @var    boolean
  49       * @since  4.0.0
  50       */
  51      protected $hiddenDescription = true;
  52  
  53      /**
  54       * Method to get the field label markup.
  55       *
  56       * @return  string  The field label markup.
  57       *
  58       * @since   1.7.0
  59       */
  60      protected function getLabel()
  61      {
  62          if (empty($this->element['label']) && empty($this->element['description'])) {
  63              return '';
  64          }
  65  
  66          $html  = [];
  67          $class = [];
  68  
  69          if (!empty($this->class)) {
  70              $class[] = $this->class;
  71          }
  72  
  73          if ($close = (string) $this->element['close']) {
  74              HTMLHelper::_('bootstrap.alert');
  75              $close   = $close === 'true' ? 'alert' : $close;
  76              $html[]  = '<button type="button" class="btn-close" data-bs-dismiss="' . $close . '"></button>';
  77              $class[] = 'alert-dismissible show';
  78          }
  79  
  80          $class       = $class ? ' class="' . implode(' ', $class) . '"' : '';
  81          $title       = $this->element['label'] ? (string) $this->element['label'] : ($this->element['title'] ? (string) $this->element['title'] : '');
  82          $heading     = $this->element['heading'] ? (string) $this->element['heading'] : 'h4';
  83          $description = (string) $this->element['description'];
  84          $html[]      = !empty($title) ? '<' . $heading . '>' . Text::_($title) . '</' . $heading . '>' : '';
  85          $html[]      = !empty($description) ? Text::_($description) : '';
  86  
  87          return '</div><div ' . $class . '>' . implode('', $html);
  88      }
  89  
  90      /**
  91       * Method to get the field input markup.
  92       *
  93       * @return  string  The field input markup.
  94       *
  95       * @since   1.7.0
  96       */
  97      protected function getInput()
  98      {
  99          return '';
 100      }
 101  }


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