public function getSanphamName()
 {
     $sanpham = Sanpham::model()->findByPk($this->sanpham_id);
     if ($sanpham) {
         return $sanpham->ten;
     } else {
         return 'Chưa Xác Định';
     }
 }
Exemplo n.º 2
0
$form = $this->beginWidget('CActiveForm', array('id' => 'chitiethoadon-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="form-group">
		<?php 
echo $form->labelEx($model, 'sanpham_id');
?>
		<?php 
echo $form->dropDownList($model, 'sanpham_id', Sanpham::model()->getSanphamsName());
?>
		<?php 
echo $form->error($model, 'sanpham_id');
?>
	</div>

	<div class="form-group">
		<?php 
echo $form->labelEx($model, 'hoadon_id');
?>
		<?php 
echo $form->dropDownList($model, 'hoadon_id', Hoadon::model()->getHoadonId());
?>
		<?php 
echo $form->error($model, 'hoadon_id');
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Sanpham the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Sanpham::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }