Skip to content

Commit

Permalink
Merge pull request #1136 from tzyganu/develop
Browse files Browse the repository at this point in the history
Fix for Textarea element cols and rows #675
  • Loading branch information
vpelipenko committed Apr 3, 2015
2 parents 64a7430 + 9cfe7c0 commit 50b6b3c
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions lib/internal/Magento/Framework/Data/Form/Element/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,28 @@

use Magento\Framework\Escaper;

/**
* @method Textarea setExtType($extType)
* @method mixed getCols()
* @method Textarea setCols($cols)
* @method mixed getRows()
* @method Textarea setRows($rows)
*/
class Textarea extends AbstractElement
{
/**
* default number of rows
*
* @var int
*/
const DEFAULT_ROWS = 2;
/**
* default number of cols
*
* @var int
*/
const DEFAULT_COLS = 15;

/**
* @param Factory $factoryElement
* @param CollectionFactory $factoryCollection
Expand All @@ -30,8 +50,12 @@ public function __construct(
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
$this->setType('textarea');
$this->setExtType('textarea');
$this->setRows(2);
$this->setCols(15);
if (!$this->getRows()) {
$this->setRows(self::DEFAULT_ROWS);
}
if (!$this->getCols()) {
$this->setCols(self::DEFAULT_COLS);
}
}

/**
Expand Down Expand Up @@ -66,8 +90,8 @@ public function getElementHtml()
{
$this->addClass('textarea');
$html = '<textarea id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" ' . $this->serialize(
$this->getHtmlAttributes()
) . $this->_getUiId() . ' >';
$this->getHtmlAttributes()
) . $this->_getUiId() . ' >';
$html .= $this->getEscapedValue();
$html .= "</textarea>";
$html .= $this->getAfterElementHtml();
Expand Down

0 comments on commit 50b6b3c

Please sign in to comment.