public function setValue($value) { if (!$value instanceof Entity) { throw new \Exception('Значение должно быть экземпляром Entity'); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/data/' . $this->dataPath . '/image/' . $value->getId() . 'thumb.jpg')) { $div = new Div(); $div->setAttribute('class', 'clearfix photos-input'); $this->append($div); $html = ' <div class="pull-left"> <div class="btn-group btn-group-sm"> <a href="/' . $this->modulePath . '/удалить-изображение/id/' . $value->getId() . '" class="btn btn-default" title="Удалить изображение"><span class="glyphicon glyphicon-remove"></span></a></div> <img src="/data/' . $this->dataPath . '/image/' . $value->getId() . 'thumb.jpg" class="img-thumbnail"> </div> '; $div->setText($html); } parent::setValue($value); }
public function setValue($value) { if ($value instanceof \ArrayObject) { $div = new Div(); $div->setAttribute('class', 'clearfix photos-input'); $this->append($div); $html = ''; foreach ($value as $entity) { /** @var \Eva\Entity\Entity $entity */ $html .= ' <div class="pull-left"> <div class="btn-group btn-group-sm"> <a href="/' . $this->modulePath . '/удалить-фото/id/' . $entity->getId() . '" class="btn btn-default" title="Удалить фото"><span class="glyphicon glyphicon-remove"></span></a></div> <img src="/data/' . $this->dataPath . '/photo/' . $entity->getId() . 'thumb.jpg" class="img-thumbnail"> </div> '; } $div->setText($html); } parent::setValue($value); }