addTextArea() size setting

radm
Member | 7
+
0
-

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

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

David Matějka
Moderator | 6445
+
0
-

or using setAttribute method:

$form->addTextArea(...)->setAttribute('rows', 5)
radm
Member | 7
+
0
-

David Matějka wrote:

or using setAttribute method:

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

Thank you both and what about width?

Phalanx
Member | 310
+
+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');
?>
radm
Member | 7
+
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!