0

In my web application, I want to set a default value to CHtml::textArea. In my view,

<?php echo CHtml::textArea('answer' . $no, '', array('rows' => 6, 'cols' => 50, 'class' => "form-control",'value'=>$exam->answer)); ?>

But, this is not working. How can I do this?

topher
  • 14,790
  • 7
  • 54
  • 70
Arya
  • 504
  • 2
  • 8
  • 31

1 Answers1

2

You can set it directly as the second parameter:

CHtml::textArea('answer' . $no, $exam->answer, array(
    'rows' => 6, 'cols' => 50, 'class' => "form-control")
);

See CHtml::textArea for more details.

topher
  • 14,790
  • 7
  • 54
  • 70