phpyiiyii-cform

Is it possible to show an image with Yii CForm formbuilder?


I'm looking for a easy way to show an image in a CForm formbuilder array. But I want to show the model contents, something like this example:

array(
    'elements'=>array(
        '<img src="$this->thumbnail" />',
        'thumbnail'=>array(
            'type'=>'file',
        ),
    ),
)

Is that possible?


Solution

  • Found it, this works.

    return array(
        'elements'=>array(
            '<img src="'.$this->getModel()->thumbnail.'" alt="" />',
            'thumbnail'=>array(
                'type'=>'file',
            ),
        ),
    );