*/ namespace Magento\Framework\Data\Form\Element; use Magento\Framework\Escaper; class Multiline extends AbstractElement { /** * @param Factory $factoryElement * @param CollectionFactory $factoryCollection * @param Escaper $escaper * @param array $data */ public function __construct( Factory $factoryElement, CollectionFactory $factoryCollection, Escaper $escaper, $data = [] ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->setType('text'); $this->setLineCount(2); } /** * @return string[] */ public function getHtmlAttributes() { return [ 'type', 'title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'maxlength', 'data-form-part', 'data-role', 'data-action' ]; } /** * @param int $suffix * @param string $scopeLabel * @return string */ public function getLabelHtml($suffix = 0, $scopeLabel = '') { return parent::getLabelHtml($suffix, $scopeLabel); } /** * Get element HTML * * @return string */ public function getElementHtml() { $html = ''; $lineCount = $this->getLineCount(); for ($i = 0; $i < $lineCount; $i++) { if ($i == 0 && $this->getRequired()) { $this->setClass('input-text admin__control-text required-entry _required'); } else { $this->setClass('input-text admin__control-text'); } $html .= '
serialize( $this->getHtmlAttributes() ) . ' ' . $this->_getUiId( $i ) . '/>' . "\n"; if ($i == 0) { $html .= $this->getAfterElementHtml(); } $html .= '
'; } return $html; } /** * @return mixed * @SuppressWarnings(PHPMD.NPathComplexity) */ public function getDefaultHtml() { $html = ''; $lineCount = $this->getLineCount(); for ($i = 0; $i < $lineCount; $i++) { $html .= $this->getNoSpan() === true ? '' : '' . "\n"; if ($i == 0) { $html .= '' . "\n"; if ($this->getRequired()) { $this->setClass('input-text required-entry'); } } else { $this->setClass('input-text'); $html .= '' . "\n"; } $html .= 'serialize( $this->getHtmlAttributes() ) . ' />' . "\n"; if ($i == 0) { $html .= $this->getAfterElementHtml(); } $html .= $this->getNoSpan() === true ? '' : '' . "\n"; } return $html; } /** * {@inheritdoc} */ public function getEscapedValue($index = null) { $value = $this->getValue(); if (is_string($value)) { $value = explode("\n", $value); if (is_array($value)) { $this->setValue($value); } } return parent::getEscapedValue($index); } }