class) ? ' class="' . $this->class . '"' : ''; $attr .= !empty($this->size) ? ' size="' . $this->size . '"' : ''; $attr .= $this->multiple ? ' multiple' : ''; $attr .= $this->required ? ' required aria-required="true"' : ''; $attr .= $this->autofocus ? ' autofocus' : ''; // To avoid user's confusion, readonly="true" should imply disabled="true". if ((string) $this->readonly == '1' || (string) $this->readonly == 'true' || (string) $this->disabled == '1'|| (string) $this->disabled == 'true') { $attr .= ' disabled="disabled"'; } // Initialize JavaScript field attributes. $attr .= $this->onchange ? ' onchange="' . $this->onchange . '"' : ''; // Get the field options. $options = (array) $this->getOptions(); // Create a read-only list (no name) with hidden input(s) to store the value(s). if ((string) $this->readonly == '1' || (string) $this->readonly == 'true') { $html[] = vHtml::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id); // E.g. form field type tag sends $this->value as array if ($this->multiple && is_array($this->value)) { if (!count($this->value)) { $this->value[] = ''; } foreach ($this->value as $value) { $html[] = ''; } } else { $html[] = ''; } } else // Create a regular list. { $html[] = vHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); } return implode($html); } /** * Method to get the field options. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { $fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname); $options = array(); foreach ($this->element->xpath('option') as $option) { // Filter requirements if ($requires = explode(',', (string) $option['requires'])) { // Requires multilanguage if (in_array('multilanguage', $requires) && !JLanguageMultilang::isEnabled()) { continue; } // Requires associations if (in_array('associations', $requires) && !JLanguageAssociations::isEnabled()) { continue; } } $value = (string) $option['value']; $text = trim((string) $option) ? trim((string) $option) : $value; $disabled = (string) $option['disabled']; $disabled = ($disabled == 'true' || $disabled == 'disabled' || $disabled == '1'); $disabled = $disabled || ($this->readonly && $value != $this->value); $checked = (string) $option['checked']; $checked = ($checked == 'true' || $checked == 'checked' || $checked == '1'); $selected = (string) $option['selected']; $selected = ($selected == 'true' || $selected == 'selected' || $selected == '1'); $tmp = array( 'value' => $value, 'text' => vmText::alt($text, $fieldname), 'disable' => $disabled, 'class' => (string) $option['class'], 'selected' => ($checked || $selected), 'checked' => ($checked || $selected) ); // Set some event handler attributes. But really, should be using unobtrusive js. $tmp['onclick'] = (string) $option['onclick']; $tmp['onchange'] = (string) $option['onchange']; // Add the option object to the result set. $options[] = (object) $tmp; } reset($options); return $options; } } /*if(JVM_VERSION>0){ //could be written abstract with eval jimport('joomla.form.formfield'); class JFormFieldList extends vFormFieldList{ public function __construct($form = null){ parent::__construct($form); vBasicModel::addIncludePath(VMPATH_ADMIN.DS.'vmf'.DS.'html','html'); VmConfig::loadJLang('com_virtuemart'); } } } */