Set cols attribute for Textarea in ZendForm

This is my code for displaying a textbox in zendform. I am showing a shallow text area with the rows I want, but if I set an attribute on cols it does not add columns to it. Code:

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

      

+2


source to share


2 answers


Two things:



  • The code for setting "cols" is commented out (// before the line)

  • Are you sure you are not setting the width of the text area in your stylesheet? As the width overwrites the cols set in your markup.

+2


source


Using:



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

      

+2


source







All Articles