E
E
EVOSandru62015-04-27 03:14:58
Yii
EVOSandru6, 2015-04-27 03:14:58

How to add default value for textField in Yii?

Good afternoon!
I tried this for an authorized user, (I checked the correct value of Yii::app()->user->EMAIL with echo):

echo $form->textField($model,'EMAIL',array('size'=>60,'maxlength'=>255),array('value'=>Yii::app()->user->EMAIL));

Did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2015-04-27
@EVOSandru6

The value in value is substituted from the corresponding model field. If it is empty, then value will be empty.

$user = User::model()->findByPk(Yii::app()->getUser()->getId());
$model->EMAIL = $user->EMAIL;
echo $form->textField($model,'EMAIL');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question