我是Yii的新手,我面临着它的问题。希望这里的一些专业人士能帮助我解决这个问题。我在网上买了一个剧本,正在根据自己的需要进行编辑。
我想要一个默认文本的文本区域。实例
Name:
Age:
Sex:
它现在正在生成什么:
<textarea class="span vertical medium" name="MAccount[accountInfo]" id="MAccount_accountInfo"></textarea>
我希望它生成什么,或者类似的东西:
<textarea class="span vertical medium" name="MAccount[accountInfo]" id="MAccount_accountInfo">Name: <br> Age: <br> Sex:</textarea>
类似上面的东西。但我只能生成一个空白/没有内容的文本区域。下面是我的代码,它位于一个工件中。;
public function properties() {
$properties = array(
'elements' => array(
'accountInfo' => array(
'type' => 'textarea',
'class' => 'span vertical medium',
),
'email' => array(
'disabled' => true,
'append' => $this->model()->role == 'unverified' ? $this->t('unverified') : $this->t('verified'),
'hint' => $this->model()->role == 'unverified' ? $this->resendBtn() : '',
),
wm()->get('project.edit.buttons', array('step' => $this->step, 'projectId' => $this->project->id))->render('tools', array(), true),
),
'model' => $this->model(),
'class' => 'projectEditForm',
);
return $properties;
}
默认值是在模型中设置的,而不是在视图中设置的。因此,您必须在model/
目录中查找正确的模型。在那里你可以添加
public $accountInfo = "Name:'nAge:'nSex:";
<?php echo CHtml::activeTextArea($form,'abc',array('value'=>"12"));?>
$form->abc="Your text goes here"
它可能会帮助您