Yii Framework Forum: TextArea set default text - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

TextArea set default text Rate Topic: -----

#1 User is offline   evoup 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 14-July 10

Posted 14 July 2010 - 05:56 AM

i use follow code to creatte a TextArea.
<?php echo CHtml::activeTextArea($form,'detail',array('value'=>"12"));?>


but how can i set the default value to the textarea

I want this result:
<textarea>12</textarea>

0

#2 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 14 July 2010 - 06:05 AM

You have to set
$form->detail = 12;
0

#3 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,017
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 14 July 2010 - 06:13 AM

You should do that in your model class ($form):

public $detail='This is the default text';


EDIT: Oh, Spyros was faster :)

This post has been edited by Mike: 14 July 2010 - 06:14 AM

0

#4 User is offline   evoup 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 14-July 10

Posted 14 July 2010 - 06:20 AM

tks,works
0

#5 User is offline   karasawaz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 14-August 12

Posted 26 September 2012 - 10:01 PM

need some help, i have a code like this
<?php echo $form->comment='tesstt'; ?>
<?php echo $form->labelEx($model,'comment'); ?>
<?php echo $form->textArea($model,'comment',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'comment'); ?>


but there is an error

Property "CActiveForm.comment" is not defined.

is there something wrong with the code?
0

#6 User is offline   MWii 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 19-September 12

Posted 26 September 2012 - 10:49 PM

View Postkarasawaz, on 26 September 2012 - 10:01 PM, said:

need some help, i have a code like this

<?php echo $form->comment='tesstt'; ?> <!-- maybe this code not used-->
<?php echo $form->labelEx($model,'comment'); ?>
<?php echo $form->textArea($model,'comment',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'comment'); ?>


but there is an error

Property "CActiveForm.comment" is not defined.

is there something wrong with the code?


i sugest that code not need to write....
0

#7 User is offline   karasawaz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 14-August 12

Posted 26 September 2012 - 10:53 PM

yes. originally is just what you mean..
But like the topic says set default text.. that's what i want :(

editted:
<?php echo $form->labelEx($model,'comment'); ?>
<?php 
$model->comment = "testcomment";
echo $form->textArea($model,'comment',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'comment'); ?>


problem solved.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users