Arya
Arya

Reputation: 504

How to set a value in CHtml::textArea in yii

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?

Upvotes: 0

Views: 2119

Answers (1)

topher
topher

Reputation: 14860

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.

Upvotes: 2

Related Questions