Including class attribute in CActiveRecord

55 views Asked by At

I have an interesting situation where I want to create an CActiveRecord that has an object as one of its attributes. That object that I am trying to reference itself has attributes.

class Offer extends CActiveRecord
{
    public $contract;

    public function init()
    {
        parent::init();
        $this->contract = new Contract_TX_9_10();
    }

The contract object itself in this example wont actually be stored to the database but used for other purposes, but it does have attributes that need to be gathered from the user.

With this I am then trying to access the attribute from my form as follows:

<?php echo $form->textField($model,'contract.cashAtClosing',array('size'=>45,'maxlength'=>45)); ?>

The error I am getting is:

Property "Offer.contract.cashAtClosing" is not defined.

Is what I am trying to do possible?

1

There are 1 answers

0
topher On

Try

<?php echo $form->textField($model->contract,'cashAtClosing',array('size'=>45,'maxlength'=>45)); ?>