Framework/Form/Element/Multiselect.php
function getElementHtml() {
		/** @var string $r */
		if (!$this->ordered()) {
			$r = parent::getElementHtml();
		}
		else {
			$r = '';
			$this->addClass('select multiselect admin__control-multiselect');
			if ($this->getCanBeEmpty()) {
				$r .= '<input type="hidden" name="' . parent::getName() . '" value="" />';
			}
			$r .=
				'<select id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" '
				. $this->serialize($this->getHtmlAttributes())
				. $this->_getUiId() . ' multiple="multiple">' . "\n"
			;
			$selectedA = $this->getValue();
			if (!is_array($selectedA)) {
				$selectedA = explode(',', $selectedA);
			}
			if ($options = $this->getValues()) {
				// 2017-09-23 BEGIN PATCH
				$options = df_map_r(function(array $o) {return [
					is_array($o['value']) ? df_uid() : $o['value'], $o
				];}, $options);
				$prepend = []; /** @var array $prepend */
				foreach ($selectedA as $selectedI) {
					/** @var string $selectedI */
					if (isset($options[$selectedI])) {
						$prepend[]= $options[$selectedI];
						unset($options[$selectedI]);
					}
				}
				$options = array_merge($prepend, $options);
				// 2017-09-23 END PATCH
				foreach ($options as $option) {
					if (is_array($option['value'])) {
						$r .= '<optgroup label="' . $option['label'] . '">' . "\n";
						foreach ($option['value'] as $groupItem) {
							$r .= $this->_optionToHtml($groupItem, $selectedA);
						}
						$r .= '</optgroup>' . "\n";
					} else {
						$r .= $this->_optionToHtml($option, $selectedA);
					}
				}
			}
			$r .= '</select>' . "\n";
			$r .= $this->getAfterElementHtml();
		}
		return $r;
	}
function getElementHtml() {
		/** @var string $r */
		if (!$this->ordered()) {
			$r = parent::getElementHtml();
		}
		else {
			$r = '';
			$this->addClass('select multiselect admin__control-multiselect');
			if ($this->getCanBeEmpty()) {
				$r .= '<input type="hidden" name="' . parent::getName() . '" value="" />';
			}
			$r .=
				'<select id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" '
				. $this->serialize($this->getHtmlAttributes())
				. $this->_getUiId() . ' multiple="multiple">' . "\n"
			;
			$selectedA = $this->getValue();
			if (!is_array($selectedA)) {
				$selectedA = explode(',', $selectedA);
			}
			if ($options = $this->getValues()) {
				// 2017-09-23 BEGIN PATCH
				$options = df_map_r(function(array $o) {return [
					is_array($o['value']) ? df_uid() : $o['value'], $o
				];}, $options);
				$prepend = []; /** @var array $prepend */
				foreach ($selectedA as $selectedI) {
					/** @var string $selectedI */
					if (isset($options[$selectedI])) {
						$prepend[]= $options[$selectedI];
						unset($options[$selectedI]);
					}
				}
				$options = array_merge($prepend, $options);
				// 2017-09-23 END PATCH
				foreach ($options as $option) {
					if (is_array($option['value'])) {
						$r .= '<optgroup label="' . $option['label'] . '">' . "\n";
						foreach ($option['value'] as $groupItem) {
							$r .= $this->_optionToHtml($groupItem, $selectedA);
						}
						$r .= '</optgroup>' . "\n";
					} else {
						$r .= $this->_optionToHtml($option, $selectedA);
					}
				}
			}
			$r .= '</select>' . "\n";
			$r .= $this->getAfterElementHtml();
		}
		return $r;
	}
function getElementHtml ( ) { /** @var string $r */ if ( ! $ this -> ordered ( ) ) { $ r = parent :: getElementHtml ( ) ; } else { $ r = '' ; $ this -> addClass ( 'select multiselect admin__control-multiselect' ) ; if ( $ this -> getCanBeEmpty ( ) ) { $ r .= '<input type="hidden" name="' . parent :: getName ( ) . '" value="" />' ; } $ r .= '<select id="' . $ this -> getHtmlId ( ) . '" name="' . $ this -> getName ( ) . '" ' . $ this -> serialize ( $ this -> getHtmlAttributes ( ) ) . $ this -> _getUiId ( ) . ' multiple="multiple">' . "\n" ; $ selectedA = $ this -> getValue ( ) ; if ( ! is_array ( $ selectedA ) ) { $ selectedA = explode ( ',' , $ selectedA ) ; } if ( $ options = $ this -> getValues ( ) ) { // 2017-09-23 BEGIN PATCH $ options = df_map_r ( function ( array $ o ) { return [ is_array ( $ o [ 'value' ] ) ? df_uid ( ) : $ o [ 'value' ] , $ o ] ; } , $ options ) ; $ prepend = [ ] ; /** @var array $prepend */ foreach ( $ selectedA as $ selectedI ) { /** @var string $selectedI */ if ( isset ( $ options [ $ selectedI ] ) ) { $ prepend [ ] = $ options [ $ selectedI ] ; unset ( $ options [ $ selectedI ] ) ; } } $ options = array_merge ( $ prepend , $ options ) ; // 2017-09-23 END PATCH foreach ( $ options as $ option ) { if ( is_array ( $ option [ 'value' ] ) ) { $ r .= '<optgroup label="' . $ option [ 'label' ] . '">' . "\n" ; foreach ( $ option [ 'value' ] as $ groupItem ) { $ r .= $ this -> _optionToHtml ( $ groupItem , $ selectedA ) ; } $ r .= '</optgroup>' . "\n" ; } else { $ r .= $ this -> _optionToHtml ( $ option , $ selectedA ) ; } } } $ r .= '</select>' . "\n" ; $ r .= $ this -> getAfterElementHtml ( ) ; } return $ r ; }
2017-09-23
@override
@see _Multiselect::getElementHtml()
@used-by \Magento\Config\Block\System\Config\Form\Field::_getElementHtml()
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) {
return $element->getElementHtml();
}
https://github.com/magento/magento2/blob/2.2.0/app/code/Magento/Config/Block/System/Config/Form/Field.php#L21-L30
@return string
2017 - 09 - 23