Skip to content

Commit c2382c5

Browse files
committed
update
1 parent dacc324 commit c2382c5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Elements.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,16 @@ public static function submit(string $caption = ''): Input
124124
return $input;
125125
}
126126

127-
public static function textarea(string $name = '', string $placeholder = ''): TextArea
127+
public static function textarea(string $name = '', int $rows = 5, string $placeholder = ''): TextArea
128128
{
129129
/** @var TextArea */
130130
$textarea = self::create('TextArea');
131131
if ($name) {
132132
$textarea->name($name);
133133
}
134+
if ($rows) {
135+
$textarea->rows($rows);
136+
}
134137
if ($placeholder) {
135138
$textarea->placeholder($placeholder);
136139
}

src/TextArea.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ class TextArea extends Input
99
{
1010
use HtmlElement;
1111

12+
protected int $rows = 0;
13+
1214
public function __construct()
1315
{
1416
$this->tag('textarea');
1517
}
1618

19+
public function rows(int $rows): self
20+
{
21+
$this->rows = $rows;
22+
return $this;
23+
}
24+
1725
public function name(string $name): self
1826
{
1927
$this->name = $name;
@@ -53,6 +61,9 @@ public function setError(string $message): void {}
5361
public function renderDom(\DOMDocument $doc): \DOMElement
5462
{
5563
$textarea = $this->renderElement($doc);
64+
if ($this->rows > 0) {
65+
$textarea->setAttribute('rows', strval($this->rows));
66+
}
5667
$textarea->setAttribute('name', $this->name);
5768
$textarea->textContent = $this->value;
5869
return $textarea;

0 commit comments

Comments
 (0)