Skip to content

Commit 50b6b3c

Browse files
committed
Merge pull request #1136 from tzyganu/develop
Fix for Textarea element cols and rows #675
2 parents 64a7430 + 9cfe7c0 commit 50b6b3c

File tree

1 file changed

+28
-4
lines changed
  • lib/internal/Magento/Framework/Data/Form/Element

1 file changed

+28
-4
lines changed

lib/internal/Magento/Framework/Data/Form/Element/Textarea.php

+28-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,28 @@
1313

1414
use Magento\Framework\Escaper;
1515

16+
/**
17+
* @method Textarea setExtType($extType)
18+
* @method mixed getCols()
19+
* @method Textarea setCols($cols)
20+
* @method mixed getRows()
21+
* @method Textarea setRows($rows)
22+
*/
1623
class Textarea extends AbstractElement
1724
{
25+
/**
26+
* default number of rows
27+
*
28+
* @var int
29+
*/
30+
const DEFAULT_ROWS = 2;
31+
/**
32+
* default number of cols
33+
*
34+
* @var int
35+
*/
36+
const DEFAULT_COLS = 15;
37+
1838
/**
1939
* @param Factory $factoryElement
2040
* @param CollectionFactory $factoryCollection
@@ -30,8 +50,12 @@ public function __construct(
3050
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
3151
$this->setType('textarea');
3252
$this->setExtType('textarea');
33-
$this->setRows(2);
34-
$this->setCols(15);
53+
if (!$this->getRows()) {
54+
$this->setRows(self::DEFAULT_ROWS);
55+
}
56+
if (!$this->getCols()) {
57+
$this->setCols(self::DEFAULT_COLS);
58+
}
3559
}
3660

3761
/**
@@ -66,8 +90,8 @@ public function getElementHtml()
6690
{
6791
$this->addClass('textarea');
6892
$html = '<textarea id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" ' . $this->serialize(
69-
$this->getHtmlAttributes()
70-
) . $this->_getUiId() . ' >';
93+
$this->getHtmlAttributes()
94+
) . $this->_getUiId() . ' >';
7195
$html .= $this->getEscapedValue();
7296
$html .= "</textarea>";
7397
$html .= $this->getAfterElementHtml();

0 commit comments

Comments
 (0)