[ 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) 2021 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 $groups Groups of 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 some field attributes. 54 $attr .= !empty($size) ? ' size="' . $size . '"' : ''; 55 $attr .= $multiple ? ' multiple' : ''; 56 $attr .= $autofocus ? ' autofocus' : ''; 57 $attr .= $dataAttribute; 58 59 // To avoid user's confusion, readonly="true" should imply disabled="true". 60 if ($readonly || $disabled) { 61 $attr .= ' disabled="disabled"'; 62 } 63 64 // Initialize JavaScript field attributes. 65 $attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : ''; 66 67 $attr2 = ''; 68 $attr2 .= !empty($class) ? ' class="' . $class . '"' : ''; 69 $attr2 .= ' placeholder="' . $this->escape($hint ?: Text::_('JGLOBAL_TYPE_OR_SELECT_SOME_OPTIONS')) . '" '; 70 71 if ($required) { 72 $attr .= ' required class="required"'; 73 $attr2 .= ' required'; 74 } 75 76 // Create a read-only list (no name) with a hidden input to store the value. 77 if ($readonly) { 78 $html[] = HTMLHelper::_( 79 'select.groupedlist', 80 $groups, 81 null, 82 array( 83 'list.attr' => $attr, 'id' => $id, 'list.select' => $value, 'group.items' => null, 'option.key.toHtml' => false, 84 'option.text.toHtml' => false, 85 ) 86 ); 87 88 // E.g. form field type tag sends $this->value as array 89 if ($multiple && \is_array($value)) { 90 if (!\count($value)) { 91 $value[] = ''; 92 } 93 94 foreach ($value as $val) { 95 $html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '">'; 96 } 97 } else { 98 $html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '">'; 99 } 100 } else { 101 // Create a regular list. 102 $html[] = HTMLHelper::_( 103 'select.groupedlist', 104 $groups, 105 $name, 106 array( 107 'list.attr' => $attr, 'id' => $id, 'list.select' => $value, 'group.items' => null, 'option.key.toHtml' => false, 108 'option.text.toHtml' => false, 109 ) 110 ); 111 } 112 113 Text::script('JGLOBAL_SELECT_NO_RESULTS_MATCH'); 114 Text::script('JGLOBAL_SELECT_PRESS_TO_SELECT'); 115 116 Factory::getApplication()->getDocument()->getWebAssetManager() 117 ->usePreset('choicesjs') 118 ->useScript('webcomponent.field-fancy-select'); 119 120 ?> 121 122 <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 |