Muhammad Sajid
Muhammad Sajid

Reputation:

Set cols attribute for Textarea in ZendForm

This is my code to display a textarea in zendform. I show fine textarea with desired rows but if i set attribute for cols it does not add columns in it. Code is this:

$element = $this->CreateElement('textarea', 'description');
$element->setAttrib('rows', '4');
$element->setAttrib('cols', '8');
$element->setLabel('Comment');

Upvotes: 2

Views: 8477

Answers (2)

pliashkou
pliashkou

Reputation: 4130

Use :

$text = new Zend_Form_Element_Textarea('Text');
$text->setOptions(array('cols' => '4', 'rows' => '4'));

Upvotes: 1

smoove
smoove

Reputation: 4000

Two things:

  1. The code for setting the "cols" is commented out (// in front of the line)

  2. are you sure that you do not set the width of the textarea in a stylesheet? Because the width overwrites the cols set in your markup.

Upvotes: 2

Related Questions