Hello,
i have a gallery with images inside (2 tables). I want one of the images to be Main Gallery image, so i list all Gallery images in gallery/update view. I do this with help of radioButton():
<?php foreach($model->files as $n=>$image):?>
<div class="image-for-main">
<?php echo CHtml::radioButton('image',$model->image_main == $image['filename'] ? true : false, array(
'value'=>$image['filename'],
'ajax' => array(
'type'=>'POST',
'url'=>$this->createUrl('estyma_gallery/mainimage',array('gallery'=>$model->id_gallery)),
// 'update'=>'#images',
'beforeSend' => 'function(){
$("#spinner").addClass("loadingon");
}',
'complete' => 'function(){
$("#spinner").removeClass("loadingoff");
}',
))), CHtml::image(bu() . '/upload/gallery/thmb_' . $image['filename']) ?>
</div>
<?php echo ($n+1)%7 == 0 ? '<div class="clear" ></div>' : null; ?>
<?php endforeach;?>
This gives me a list of radio buttons with images by each. Then when i click on any radio button, it launches a controller action:
public function actionMainimage()
{
$toChange = $_POST['image'];
$gallery = $_GET['gallery'];
$gal = a_gallery::model()->findByPk($gallery);
$gal->obraz = $toChange;
if($gal->save())
echo 'saved';
}
All is ok, the filename of image ive chosen, writes to DB in proper way, but i don
t know what to do to refresh the view. I tried to do redirect(), but it does nothing:
$this->redirect(array('a_gallery/update','id'=>$gallery),true);
(firebug says OK, but nothing changes, page doesn`t refresh)
I also tried $this->refresh(); but also no effect.
Anyone can help me with this?