addTextArea() size setting

5 months ago

radm
Member | 3
+
0
-

Hi, I am a beginner and cannot find how to set a size of element added by addTextArea(). Many thanks for help.

5 months ago

Phalanx
Member | 231
+
0
-

You can add parameter in latte template or set it in form initialization

<?php
{input example, rows => 5}

$form->addTextArea('example', 'Example')->setAttribute('rows', 5);
?>

Last edited by Phalanx (2018-06-29 14:08)

5 months ago

David Matějka
Moderator | 5681
+
0
-

or using setAttribute method:

$form->addTextArea(...)->setAttribute('rows', 5)

5 months ago

radm
Member | 3
+
0
-

David Matějka wrote:

or using setAttribute method:

$form->addTextArea(...)->setAttribute('rows', 5)

Thank you both and what about width?

5 months ago

Phalanx
Member | 231
+
+1
-

It's better to use class rather than style attribute.

<?php
// you can use this latte
{input example, rows => 5, class => 'form-control orSomeOtherClass'}

// or in form init
$form->addTextArea('example', 'Example')->setAttribute('rows', 5)->getControlPrototype()->addClass('form-control');
?>

5 months ago

radm
Member | 3
+
0
-

Phalanx wrote:

It's better to use class rather than style attribute.

<?php
// you can use this latte
{input example, rows => 5, class => 'form-control orSomeOtherClass'}

// or in form init
$form->addTextArea('example', 'Example')->setAttribute('rows', 5)->getControlPrototype()->addClass('form-control');
?>

getControlPrototype() and addClass() is what I needed. Thanks!