addTextArea() size setting

20 days 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.

20 days ago

Phalanx
Member | 163
+
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)

20 days ago

David Matějka
Moderator | 5518
+
0
-

or using setAttribute method:

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

20 days 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?

19 days ago

Phalanx
Member | 163
+
+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');
?>

17 days 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!