[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/layouts/joomla/form/field/ -> text.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Layout
   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  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Language\Text;
  14  
  15  extract($displayData);
  16  
  17  /**
  18   * Layout variables
  19   * -----------------
  20   * @var   string   $autocomplete    Autocomplete attribute for the field.
  21   * @var   boolean  $autofocus       Is autofocus enabled?
  22   * @var   string   $class           Classes for the input.
  23   * @var   string   $description     Description of the field.
  24   * @var   boolean  $disabled        Is this field disabled?
  25   * @var   string   $group           Group the field belongs to. <fields> section in form XML.
  26   * @var   boolean  $hidden          Is this field hidden in the form?
  27   * @var   string   $hint            Placeholder for the field.
  28   * @var   string   $id              DOM id of the field.
  29   * @var   string   $label           Label of the field.
  30   * @var   string   $labelclass      Classes to apply to the label.
  31   * @var   boolean  $multiple        Does this field support multiple values?
  32   * @var   string   $name            Name of the input field.
  33   * @var   string   $onchange        Onchange attribute for the field.
  34   * @var   string   $onclick         Onclick attribute for the field.
  35   * @var   string   $pattern         Pattern (Reg Ex) of value of the form field.
  36   * @var   boolean  $readonly        Is this field read only?
  37   * @var   boolean  $repeat          Allows extensions to duplicate elements.
  38   * @var   boolean  $required        Is this field required?
  39   * @var   integer  $size            Size attribute of the input.
  40   * @var   boolean  $spellcheck      Spellcheck state for the form field.
  41   * @var   string   $validate        Validation rules to apply.
  42   * @var   string   $value           Value attribute of the field.
  43   * @var   array    $checkedOptions  Options that will be set as checked.
  44   * @var   boolean  $hasValue        Has this field a value assigned?
  45   * @var   array    $options         Options available for this field.
  46   * @var   array    $inputType       Options available for this field.
  47   * @var   string   $accept          File types that are accepted.
  48   * @var   string   $dataAttribute   Miscellaneous data attributes preprocessed for HTML output
  49   * @var   array    $dataAttributes  Miscellaneous data attribute for eg, data-*.
  50   * @var   string   $dirname         The directory name
  51   * @var   string   $addonBefore     The text to use in a bootstrap input group prepend
  52   * @var   string   $addonAfter      The text to use in a bootstrap input group append
  53   */
  54  
  55  $list = '';
  56  
  57  if ($options) {
  58      $list = 'list="' . $id . '_datalist"';
  59  }
  60  
  61  $attributes = array(
  62      !empty($class) ? 'class="form-control ' . $class . '"' : 'class="form-control"',
  63      !empty($size) ? 'size="' . $size . '"' : '',
  64      !empty($description) ? 'aria-describedby="' . ($id ?: $name) . '-desc"' : '',
  65      $disabled ? 'disabled' : '',
  66      $readonly ? 'readonly' : '',
  67      $dataAttribute,
  68      $list,
  69      strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
  70      $onchange ? ' onchange="' . $onchange . '"' : '',
  71      !empty($maxLength) ? $maxLength : '',
  72      $required ? 'required' : '',
  73      !empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
  74      $autofocus ? ' autofocus' : '',
  75      $spellcheck ? '' : 'spellcheck="false"',
  76      !empty($inputmode) ? $inputmode : '',
  77      !empty($pattern) ? 'pattern="' . $pattern . '"' : '',
  78  
  79      // @TODO add a proper string here!!!
  80      !empty($validationtext) ? 'data-validation-text="' . $validationtext . '"' : '',
  81  );
  82  
  83  $addonBeforeHtml = '<span class="input-group-text">' . Text::_($addonBefore) . '</span>';
  84  $addonAfterHtml  = '<span class="input-group-text">' . Text::_($addonAfter) . '</span>';
  85  ?>
  86  
  87  <?php if (!empty($addonBefore) || !empty($addonAfter)) : ?>
  88  <div class="input-group">
  89  <?php endif; ?>
  90  
  91      <?php if (!empty($addonBefore)) : ?>
  92          <?php echo $addonBeforeHtml; ?>
  93      <?php endif; ?>
  94  
  95      <input
  96          type="text"
  97          name="<?php echo $name; ?>"
  98          id="<?php echo $id; ?>"
  99          value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
 100          <?php echo $dirname; ?>
 101          <?php echo implode(' ', $attributes); ?>>
 102  
 103      <?php if (!empty($addonAfter)) : ?>
 104          <?php echo $addonAfterHtml; ?>
 105      <?php endif; ?>
 106  
 107  <?php if (!empty($addonBefore) || !empty($addonAfter)) : ?>
 108  </div>
 109  <?php endif; ?>
 110  
 111  <?php if ($options) : ?>
 112      <datalist id="<?php echo $id; ?>_datalist">
 113          <?php foreach ($options as $option) : ?>
 114              <?php if (!$option->value) : ?>
 115                  <?php continue; ?>
 116              <?php endif; ?>
 117              <option value="<?php echo $option->value; ?>"><?php echo $option->text; ?></option>
 118          <?php endforeach; ?>
 119      </datalist>
 120  <?php endif; ?>


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