public function initialize() { $type = new Select('type_id', Type::cachedListArray(['key' => 'id'])); $type->setLabel('Type of Publication'); $this->add($type); $title = new Text('title', ['required' => true]); $title->addValidator(new PresenceOf(['message' => 'Title can not be empty'])); $title->setLabel('Title'); $this->add($title); $slug = new Text('slug'); $slug->setLabel('Slug'); $this->add($slug); $date = new Text('date'); $date->setLabel('Publication Date'); $this->add($date); $text = new TextArea('text'); $text->setLabel('Text'); $this->add($text); $meta_title = new Text('meta_title', ['required' => true]); $meta_title->setLabel('meta-title'); $this->add($meta_title); $meta_description = new TextArea('meta_description', ['style' => 'height:4em; min-height: inherit']); $meta_description->setLabel('meta-description'); $this->add($meta_description); $meta_keywords = new TextArea('meta_keywords', ['style' => 'height:4em; min-height: inherit']); $meta_keywords->setLabel('meta-keywords'); $this->add($meta_keywords); $preview_inner = new Check('preview_inner'); $preview_inner->setLabel('Show preview image inside publication'); $this->add($preview_inner); $image = new Image('preview_src'); $image->setLabel('Thumbnail Image'); $this->add($image); }
/** * @param Image $element * @return string $html */ private function renderImage($element) { $html = '<div class="form-group">'; if ($element->getLabel()) { $html .= '<label>' . $element->getLabel() . '</label>'; } if ($element->getValue()) { $html .= '<section onclick="selectText(this);">' . $element->getValue() . '</section>'; } else { $html .= '<br>'; } $html .= '<div class="fileinput fileinput-new" data-provides="fileinput"> <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; min-height: 100px">'; if ($element->getValue()) { $url = $this->getDI()->get('url'); $html .= '<img src="' . $url->path() . $element->getValue() . '" width="200">'; } $html .= '</div> <div> <span class="btn btn-default btn-file"> <span class="fileinput-new">Select image</span> <span class="fileinput-exists">Change</span> <input type="file" name="' . $element->getName() . '"> </span> <a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a> </div> </div> </div>'; return $html; }