首先在model中进行表关联
public function relations() {
return array_merge(parent::relations(), array(
'OrderAddonGiftinstock' => array (self::HAS_ONE, 'OrderAddonGiftinstock', 'order_id' ),
));
}
在增加和修改的页面用下面的代码来表示
<td width=100>
<div class="bh-text bh-show_inline">
<?php echo $form->textField($model->s('Addon'),'telephone', array(
'name' => HActiveForm::name($model, '[Addon]', 'telephone'),
'pattern'=>'(0(10|2[0-5789]|\\d{3})-?\\d{7,8})?',
'error'=>'错误的电话号'
)); ?>
</div>
</td>
在查看页面读取数据为
<?php echo $model->OrderAddonGiftinstock->telephone;?>