swisscheese
(Swisscheese2122)
February 15, 2012, 3:26am
1
Is it possible to display a image stored in a db from a related model?
It’s simple enough when viewing within the same model following this link
and using this
<? echo CHtml::link(my_link_name,array('displaySavedImage','id'=>$model->primaryKey)); ?>
but now I want to display an image from a related model. Any ideas?
redguy
(Maciej Lizewski)
February 15, 2012, 8:11am
2
<? echo CHtml::link(my_link_name,array('displayRelatedImage','id'=>$model->related->primaryKey)); ?>
swisscheese
(Swisscheese2122)
February 15, 2012, 10:19am
3
I have tried this even with specifying the controller/displayImage and get nothing. Have you got this working?
redguy
(Maciej Lizewski)
February 15, 2012, 11:02am
4
provide error message you get (or results), model(s) code, etc. it is realy hard to think why something is not working without seeing it…
swisscheese
(Swisscheese2122)
February 15, 2012, 4:24pm
5
Ok this is what got things working. I changed the relation to HAS_ONE although if you implode the array for HAS_MANY it should work the same although didn’t test.
$dbImage = $this->createUrl('model/displaySavedImage',array('id'=>$model->related->primaryKey));
echo CHtml::image($dbImage,'image');