Hi all,
I’m going crazy right now…
I have to retrieve data from 3 tables and I’m reading through solutions all over the internet, but still there is this error: ‘Relation “mgb_bewerber_berufe_zt” is not defined in ActiveRecord-Class “mgb_bewerber”’…
Here’s my code:
- Model mgb_bewerber => Relations
public $mgb_berufsbez;
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'bewerber'=>array(self::HAS_MANY,'mgb_bewerber_berufe_zt','mgb_bewerber_id'),
'berufe'=>array(self::HAS_MANY,'mgb_berufe','mgb_berufe_id','through'=>'mgb_bewerber_berufe_zt'),
);
}
- Controller
public function actionAdmin()
{
$model=new mgb_bewerber('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['mgb_bewerber']))
$model->attributes=$_GET['mgb_bewerber'];
$this->render('bewerberSuche',array(
'model'=>$model,
));
}
- View
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'mgb-bewerber-grid',
'filter'=>$model->with('bewerber','berufe')->together()->findAll(),
'columns'=>array(
'mgb_bewerber_id',
'mgb_vorname',
'mgb_nachname',
'mgb_strasse_hnr',
'mgb_plz',
'mgb_ort',
'mgb_berufsbez',
'mgb_angelegt',
'mgb_angelegt_von',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
I’m really grateful for every clue I can get…
Thanks in advance,
thion007