screenshot I can not publish because at the moment there is no access to the site. I can only code
//model
public function rules() {
return array(
array('gallery_id', 'required'),
array('name', 'file', 'types' => 'jpg, png, jpeg', 'allowEmpty' => true, 'safe' => false),
);
}
public function relations() {
return array(
'gallery' => array(self::BELONGS_TO, 'Gallery', 'gallery_id'),
);
}
public function search() {
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id, true);
$criteria->compare('name', $this->name, true);
$criteria->compare('gallery_id', $this->gallery_id, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
));
}
//view
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
array(
'name' => 'name',
'type' => 'image',
'value' => '"/uploads/img_" . CHtml::encode($data->name)'
),
array(
'name' => 'gallery_id',
'value' => '$data->gallery->name',
'filter' => CHtml::listData(Gallery::model()->findAll(), 'id', 'name'),
),
array(
'name' => 'gallery.albums_id',
'value' => '$data->gallery->albums->title',
),
array(
'class' => 'CButtonColumn',
),
),
));