[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2011 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   * Supports a text field telephone numbers.
  19   *
  20   * @link   https://html.spec.whatwg.org/multipage/input.html#telephone-state-(type=tel)
  21   * @see    \Joomla\CMS\Form\Rule\TelRule for telephone number validation
  22   * @see    JHtmlTel for rendering of telephone numbers
  23   * @since  1.7.0
  24   */
  25  class TelephoneField extends TextField
  26  {
  27      /**
  28       * The form field type.
  29       *
  30       * @var    string
  31       * @since  1.7.0
  32       */
  33      protected $type = 'Telephone';
  34  
  35      /**
  36       * Name of the layout being used to render the field
  37       *
  38       * @var    string
  39       * @since  3.7.0
  40       */
  41      protected $layout = 'joomla.form.field.tel';
  42  
  43      /**
  44       * Method to get the field input markup.
  45       *
  46       * @return  string  The field input markup.
  47       *
  48       * @since   3.2
  49       */
  50      protected function getInput()
  51      {
  52          // Trim the trailing line in the layout file
  53          return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
  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.7.0
  62       */
  63      protected function getLayoutData()
  64      {
  65          $data = parent::getLayoutData();
  66  
  67          // Initialize some field attributes.
  68          $maxLength    = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
  69  
  70          $extraData = array(
  71              'maxLength' => $maxLength,
  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