Exemplo n.º 1
0
 public function initialize()
 {
     $type = new Select('type', Publication::$types, array());
     $type->setLabel('Тип пубикации');
     $this->add($type);
     $title = new Text('title', array('required' => true));
     $title->setLabel('Название');
     $this->add($title);
     $slug = new Text('slug');
     $slug->setLabel('Транслитерация');
     $this->add($slug);
     $date = new Text('date');
     $date->setLabel('Дата публикации');
     $this->add($date);
     $text = new TextArea('text');
     $text->setLabel('Текст');
     $this->add($text);
     $meta_title = new Text('meta_title', array('required' => true));
     $meta_title->setLabel('meta-title');
     $this->add($meta_title);
     $meta_description = new TextArea('meta_description');
     $meta_description->setLabel('meta-description');
     $this->add($meta_description);
     $meta_keywords = new TextArea('meta_keywords');
     $meta_keywords->setLabel('meta-keywords');
     $this->add($meta_keywords);
     $preview_inner = new Check('preview_inner');
     $preview_inner->setLabel('Превью внутри публикации');
     $preview_inner->setDefault(1);
     $this->add($preview_inner);
     $image = new File('image');
     $image->setLabel('Загрузить превью');
     $this->add($image);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 public function initialize()
 {
     $title = new Text('title', array('required' => true));
     $title->setLabel('Название объекта');
     $this->add($title);
     $location = new Text('location', array('required' => true));
     $location->setLabel('Расположение, адрес');
     $this->add($location);
     $description = new TextArea('description');
     $description->setLabel('Описание, системы');
     $this->add($description);
     $visible = new Check('visible');
     $visible->setLabel('Отображать');
     $visible->setDefault(1);
     $this->add($visible);
     $sortorder = new Text('sortorder');
     $sortorder->setLabel('Сортировка');
     $this->add($sortorder);
     $image = new File('image');
     $image->setLabel('Загрузить изображение');
     $this->add($image);
 }
Exemplo n.º 4
0
 public function initialize($entity = null, $options = null)
 {
     //In edition the id is hidden
     if (isset($options['edit']) && $options['edit']) {
         $id = new Hidden('id');
     } else {
         $id = new Text('id');
     }
     $this->add($id);
     $fileCaption = new Text('fileCaption', array('placeholder' => $this->request->getPost('fileCaption')));
     $fileCaption->setLabel(_('Caption'));
     $fileCaption->addValidators(array(new PresenceOf(array('message' => _('Document caption not null')))));
     $this->add($fileCaption);
     $fileData = new File('fileData');
     $fileData->setLabel('Document upload');
     /*$fileData->addValidators(array(
     			new PresenceOf(array(
     				'message' =>_('Document file required')
     				))
     		));*/
     $this->add($fileData);
     //render if action is edit
     $fileDataEdit = new File('fileDataEdit');
     $fileDataEdit->setLabel('Document upload');
     /*$fileData->addValidators(array(
     			new PresenceOf(array(
     				'message' =>_('Document file required')
     				))
     		));*/
     $this->add($fileDataEdit);
     $categories = new Select('categoriesId', Categories::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '----', 'emptyValue' => ''));
     $categories->setLabel('Categories');
     $this->add($categories);
     $description = new TextArea('description', array('placeholder' => ' Enter text ...', 'class' => 'span8', 'rows' => '6'));
     $description->addValidator(new PresenceOf(array('message' => _('The description is required'))));
     $description->setLabel('Description');
     $this->add($description);
     $this->add(new Text('q', array('placeholder' => $this->request->getPost('q', 'striptags'))));
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
 public function initialize($entity = null, $options = array())
 {
     if (!isset($options['edit'])) {
         $element = new Text("id");
         $this->add($element->setLabel("Id"));
     } else {
         $this->add(new Hidden("id"));
     }
     $name = new Text("name");
     $name->addValidator(new PresenceOf(array('message' => 'The name is required')));
     $name->setLabel("名称");
     $this->add($name);
     $category = new Select('category_id', Category::find("isParent=0 and status=1"), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => ''));
     $category->setLabel('类型');
     $this->add($category);
     $country = new Select('country_id', Country::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => ''));
     $country->setLabel('国家');
     $this->add($country);
     $price = new Text("price");
     $price->setLabel("价格");
     $this->add($price);
     $stock = new Text("stock");
     $stock->setLabel("库存");
     $this->add($stock);
     $color = new Text("color");
     $color->addValidator(new PresenceOf(array('message' => 'The color is required')));
     $color->setLabel("颜色");
     $this->add($color);
     $size = new Text("size");
     $size->addValidator(new PresenceOf(array('message' => 'The size is required')));
     $size->setLabel("尺码");
     $this->add($size);
     $covImg = new File("covImg");
     $covImg->setLabel("主图");
     $this->add($covImg);
 }
Exemplo n.º 7
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);
 }