[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage Layout 6 * 7 * @copyright (C) 2018 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\Factory; 14 use Joomla\CMS\HTML\HTMLHelper; 15 use Joomla\CMS\Language\Text; 16 17 extract($displayData); 18 19 /** 20 * Layout variables 21 * ----------------- 22 * @var string $autocomplete Autocomplete attribute for the field. 23 * @var boolean $autofocus Is autofocus enabled? 24 * @var string $class Classes for the input. 25 * @var string $description Description of the field. 26 * @var boolean $disabled Is this field disabled? 27 * @var string $group Group the field belongs to. <fields> section in form XML. 28 * @var boolean $hidden Is this field hidden in the form? 29 * @var string $hint Placeholder for the field. 30 * @var string $id DOM id of the field. 31 * @var string $label Label of the field. 32 * @var string $labelclass Classes to apply to the label. 33 * @var boolean $multiple Does this field support multiple values? 34 * @var string $name Name of the input field. 35 * @var string $onchange Onchange attribute for the field. 36 * @var string $onclick Onclick attribute for the field. 37 * @var string $pattern Pattern (Reg Ex) of value of the form field. 38 * @var boolean $readonly Is this field read only? 39 * @var boolean $repeat Allows extensions to duplicate elements. 40 * @var boolean $required Is this field required? 41 * @var integer $size Size attribute of the input. 42 * @var boolean $spellcheck Spellcheck state for the form field. 43 * @var string $validate Validation rules to apply. 44 * @var string $value Value attribute of the field. 45 * @var array $options Options available for this field. 46 * @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output 47 * @var array $dataAttributes Miscellaneous data attribute for eg, data-* 48 */ 49 50 $html = array(); 51 $attr = ''; 52 53 // Initialize the field attributes. 54 $attr .= !empty($size) ? ' size="' . $size . '"' : ''; 55 $attr .= $multiple ? ' multiple' : ''; 56 $attr .= $autofocus ? ' autofocus' : ''; 57 $attr .= $onchange ? ' onchange="' . $onchange . '"' : ''; 58 $attr .= $dataAttribute; 59 60 // To avoid user's confusion, readonly="readonly" should imply disabled="disabled". 61 if ($readonly || $disabled) { 62 $attr .= ' disabled="disabled"'; 63 } 64 65 $attr2 = ''; 66 $attr2 .= !empty($class) ? ' class="' . $class . '"' : ''; 67 $attr2 .= ' placeholder="' . $this->escape($hint ?: Text::_('JGLOBAL_TYPE_OR_SELECT_SOME_OPTIONS')) . '" '; 68 69 if ($required) { 70 $attr .= ' required class="required"'; 71 $attr2 .= ' required'; 72 } 73 74 // Create a read-only list (no name) with hidden input(s) to store the value(s). 75 if ($readonly) { 76 $html[] = HTMLHelper::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $value, $id); 77 78 // E.g. form field type tag sends $this->value as array 79 if ($multiple && is_array($value)) { 80 if (!count($value)) { 81 $value[] = ''; 82 } 83 84 foreach ($value as $val) { 85 $html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '">'; 86 } 87 } else { 88 $html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '">'; 89 } 90 } else // Create a regular list. 91 { 92 $html[] = HTMLHelper::_('select.genericlist', $options, $name, trim($attr), 'value', 'text', $value, $id); 93 } 94 95 Text::script('JGLOBAL_SELECT_NO_RESULTS_MATCH'); 96 Text::script('JGLOBAL_SELECT_PRESS_TO_SELECT'); 97 98 Factory::getApplication()->getDocument()->getWebAssetManager() 99 ->usePreset('choicesjs') 100 ->useScript('webcomponent.field-fancy-select'); 101 102 ?> 103 104 <joomla-field-fancy-select <?php echo $attr2; ?>><?php echo implode($html); ?></joomla-field-fancy-select>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |