[ 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 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 $options Options available for this field. 44 * @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output 45 * @var array $dataAttributes Miscellaneous data attributes for eg, data-*. 46 */ 47 48 // If there are no options don't render anything 49 if (empty($options)) { 50 return ''; 51 } 52 53 // Load the css files 54 Factory::getApplication()->getDocument()->getWebAssetManager()->useStyle('switcher'); 55 56 /** 57 * The format of the input tag to be filled in using sprintf. 58 * %1 - id 59 * %2 - name 60 * %3 - value 61 * %4 = any other attributes 62 */ 63 $input = '<input type="radio" id="%1$s" name="%2$s" value="%3$s" %4$s>'; 64 65 $attr = 'id="' . $id . '"'; 66 $attr .= $onchange ? ' onchange="' . $onchange . '"' : ''; 67 $attr .= $dataAttribute; 68 69 ?> 70 <fieldset <?php echo $attr; ?>> 71 <legend class="visually-hidden"> 72 <?php echo $label; ?> 73 </legend> 74 <div class="switcher<?php echo ($readonly || $disabled ? ' disabled' : ''); ?>"> 75 <?php foreach ($options as $i => $option) : ?> 76 <?php 77 // False value casting as string returns an empty string so assign it 0 78 if (empty($value) && $option->value == '0') { 79 $value = '0'; 80 } 81 82 // Initialize some option attributes. 83 $optionValue = (string) $option->value; 84 $optionId = $id . $i; 85 $attributes = $optionValue == $value ? 'checked class="active ' . $class . '"' : ($class ? 'class="' . $class . '"' : ''); 86 $attributes .= $optionValue != $value && $readonly || $disabled ? ' disabled' : ''; 87 ?> 88 <?php echo sprintf($input, $optionId, $name, $this->escape($optionValue), $attributes); ?> 89 <?php echo '<label for="' . $optionId . '">' . $option->text . '</label>'; ?> 90 <?php endforeach; ?> 91 <span class="toggle-outside"><span class="toggle-inside"></span></span> 92 </div> 93 </fieldset>
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 |