Daantje
Daantje

Reputation: 2486

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?

Upvotes: 1

Views: 109

Answers (1)

Daantje
Daantje

Reputation: 2486

Found it, this works.

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

Upvotes: 1

Related Questions