Exemple #1
0
 public function render($attributes = [])
 {
     $entity = $this->getForm()->getEntity();
     $image = '';
     $methodName = 'get' . ucfirst($this->getName());
     if (method_exists($entity, $methodName) && $entity->id && $entity->{$this->getName()}) {
         $image = '<img id="loaded-image" style="max-height: 200px;" src="' . $entity->{$methodName}() . '">';
     }
     return $image . parent::render($attributes);
 }
Exemple #2
0
 public function render($attributes = null)
 {
     $return = '';
     if (!empty($this->_previous_value)) {
         $return .= '<div>New uploads will replace your existing files. View existing files: ';
         $existing_files = array();
         foreach ((array) $this->_previous_value as $file) {
             $file_url = \PVL\Url::upload($file);
             $existing_files[] = '<a href="' . $file_url . '" target="_blank">Download</a>';
         }
         $return .= implode(', ', $existing_files) . '</div>';
     }
     $return .= parent::render($attributes);
     return $return;
 }
Exemple #3
0
 public function render($attributes = array())
 {
     $attributes = $this->getAttributes();
     $fileElement = new Element\File($this->name);
     foreach ($attributes as $name => $value) {
         $fileElement->setAttribute('data-' . $name, $value);
     }
     $fileElement->setAttribute('vegas-cmf', 'upload');
     $fileElement->setAttribute('max-files', $this->maxFiles);
     $fileElement->setAttribute('upload-url', $this->uploadUrl);
     $fileElement->setAttribute('min-file-size', $this->minFileSize);
     $fileElement->setAttribute('max-file-size', $this->maxFileSize);
     $fileElement->setAttribute('browser-type', $this->browserType);
     $fileElement->setAttribute('browser-label', $this->browserLabel);
     $fileElement->setAttribute('allowed-extensions', implode(',', $this->allowedExtensions));
     $fileElement->setAttribute('forbidden-extensions', implode(',', $this->forbiddenExtensions));
     $fileElement->setAttribute('allowed-mime-types', implode(',', $this->allowedMimeTypes));
     $fileElement->setAttribute('forbidden-mime-types', implode(',', $this->forbiddenMimeTypes));
     return $fileElement->render($attributes);
 }