Textfield Value From Other Model Attribute

Sorry my english is not good…

How to make Textfield value from other Model’s attribute??

I want to textfield disabled, and contains the value of attributes another model

This my Controller:

public $clientpoint = array();

protected function beforeAction(CAction $action) {


    return true;


protected function populateClientpoint() {

    if (!$this->clientpoint) {

        $user = Yii::app()->user->getState(Yii::app()->params['key_user']);

        $queries = Yii::app()->db->createCommand()->select("id,point")->from("clientpoint")

            ->where('client_id=:clientId', array(':clientId'=>$user->client_id))


        $this->clientpoint = array();

        foreach($queries as $ckey => $value) {

            $this->clientpoint[$value['id']] = $value['point'];




and This my _Form :

<div class="row"><h3>

<?php echo $form->labelEx($model, 'Remaining Token: ') ; ?>

<?php echo $form->textField($model,‘point’,array(‘value’=>$this->clientpoint,‘disabled’=>‘disabled’)); ?>


why i got eror:

htmlspecialchars() expects parameter 1 to be string, array given

What should i do???? help :(

How to make Textfield value from other Model’s attribute??

you can try like this

<?php echo $form->textField($model,‘point’,array(‘value’=>$othermodel->clientpoint,‘disabled’=>‘disabled’)); ?>

i think your $this->clientpoint is an array!!


The Problem is you have to render properly the variable clientpoint to the view page and it should be a string

Thanks Kumar, I try but didn’t work,

point (int) is in table: client_point , or in model: Clientpoint.

If i made like this:

<?php echo $form->dropDownList($model, ‘point’, array($this->clientpoint)); ?>

It works, automatically filled value from model clientpoint, but what i want is textField, not dropDownList.

Because the value is number and just one, not array.

i don’t know how… I’m newbii…