0
私はSymfony 2.8とSonata ORMとSonata Adminバンドルを使用しています。Sonata AdminのShow Actionに画像を表示するには?
私はthisを使用して編集アクションで画像を表示しますが、正常に動作します。
私はショーのアクションで画像を表示したい、との命令がImageAdmin
protected function configureShowFields(ShowMapper $showMapper)
{
if($this->hasParentFieldDescription()) { // this Admin is embedded
// $getter will be something like 'getlogoImage'
$getter = 'get' . $this->getParentFieldDescription()->getFieldName();
// get hold of the parent object
$parent = $this->getParentFieldDescription()->getAdmin()->getSubject();
if ($parent) {
$image = $parent->$getter();
} else {
$image = null;
}
} else {
$image = $this->getSubject();
}
// use $fileFieldOptions so we can add other options to the field
$fileFieldOptions = array('required' => false);
if ($image && ($webPath = $image->getWebPath())) {
// add a 'help' option containing the preview's img tag
$fileFieldOptions['help'] = '<img src="'.$webPath.'" class="admin-preview" />';
}
$showMapper->add('file', 'file', $fileFieldOptions);
}
の内部configureShowFieldsでは動作しません。しかし、それはあなたがこれを見て持つことができる埋め込み管理