great explanation bro,
unfortunately me , i still found many error,
my invoice/view.php script :
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'invoice-grid',
'dataProvider'=>new CActiveDataProvider("Post",array
(
'criteria'=>array(
'condition'=>'invoice_id=:id',
'params'=>array(":id"=>$model->invoice_id),
),
)
),
'columns'=>array(
'idSpekLokasi',
'namaSpek',
'ketSpek',
//'title',
array(
'class'=>'CButtonColumn', ),
),
));
my controller looks :
public function actionView($id)
{
$invoice = Invoice::model()->findByPk($id);
$invoice ->foods;
$invoice ->drinks;
$this->render('view', array(
'invoice' => $invoice,
));
//$this->render('view',array(
//'model'=>$this->loadModel($id),
//));
}
honestly i really doubt about this part,
-
is it right to put the code under the actionView()?
-
did the code really like these?
and the relations() in my invoice model = Invoice.php
'foods' => array(self::HAS_MANY, 'Invoice', 'invoice_id'),
'drinks' => array(self::HAS_MANY, 'Invoice','invoice_id'),
the error was
" Please specify the "data" property. "
* @var string the URL of the CSS file used by this detail view. Defaults to null, meaning using the integrated
126 * CSS file. If this is set false, you are responsible to explicitly include the necessary CSS file in your page.
127 */
128 public $cssFile;
129
130 /**
131 * Initializes the detail view.
132 * This method will initialize required property values.
133 */
134 public function init()
135 {
136 if($this->data===null)
137 throw new CException(Yii::t('zii','Please specify the "data" property.'));
138 if($this->attributes===null)
139 {
140 if($this->data instanceof CModel)
141 $this->attributes=$this->data->attributeNames();
142 else if(is_array($this->data))
143 $this->attributes=array_keys($this->data);
144 else
145 throw new CException(Yii::t('zii','Please specify the "attributes" property.'));
146 }
147 if($this->nullDisplay===null)
148 $this->nullDisplay='<span class="null">'.Yii::t('zii','Not set').'</span>';
149 $this->htmlOptions['id']=$this->getId();
and when i changed the actionView() controller into default, i got this error :
"include(Post.php): failed to open stream: No such file or directory "
i wonder that where was the mistake that i’ve made,
do you have any solution for such condition bro? i really wonder to know…
my best regards bro,
thanks.