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); }
/** * Set default value * * @param mixed $value * @return \Engine\Forms\Element\Check */ public function setDefault($value) { if ($value == true) { $this->setAttribute('checked', 'checked'); } else { $attributes = $this->getAttributes(); unset($attributes['checked']); $this->setAttributes($attributes); } parent::setDefault($value); }
private function addFIelds($device) { $name = new Text('devices[' . $device->id . '][name]'); $name->setLabel('Devicename'); $name->setFilters(array('striptags', 'string')); $name->setAttributes(array('class' => 'form-control')); $name->setDefault($device->name); $name->addValidators(array(new PresenceOf(array()))); $ip = new Text('devices[' . $device->id . '][ip]'); $ip->setLabel('IP'); $ip->setFilters(array('striptags', 'string')); $ip->setAttributes(array('class' => 'form-control')); $ip->setDefault($device->ip); $ip->addValidator(new Regex(array('pattern' => '/^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/'))); $mac = new Text('devices[' . $device->id . '][mac]'); $mac->setLabel('MAC'); $mac->setFilters(array('striptags', 'string')); $mac->setAttributes(array('class' => 'form-control')); $mac->setDefault($device->mac); $mac->addValidator(new Regex(array('pattern' => '/^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$/'))); $webtemp = new Text('devices[' . $device->id . '][webtemp]'); $webtemp->setLabel('Webtemp path'); $webtemp->setFilters(array('striptags', 'string')); $webtemp->setAttributes(array('class' => 'form-control')); $webtemp->setDefault($device->webtemp); $shutdownMethod = new Select('devices[' . $device->id . '][shutdown_method]', array('none' => 'None', 'rpc' => 'RPC'), array('useEmpty' => false)); $shutdownMethod->setDefault($device->shutdown_method); $showDasboard = new Check('devices[' . $device->id . '][show_on_dashboard]'); $showDasboard->setLabel('Show on dashboard'); $showDasboard->setFilters(array('striptags', 'int')); $showDasboard->setAttributes(array('class' => 'form-control')); $showDasboard->setDefault($device->show_on_dashboard); $id = new Hidden('devices[' . $device->id . '][id]'); $id->setDefault($device->id); $this->add($name); $this->add($ip); $this->add($mac); $this->add($webtemp); $this->add($shutdownMethod); $this->add($showDasboard); $this->add($id); }
public function initialize() { $type = new Select("type", ['once' => 'Only once', 'repetitiv' => 'Repetitiv']); $type->setLabel('Run type:'); $this->add($type); $time = new DateTimeSelector("datetime"); $time->setLabel('Run once at:'); $this->add($time); $job_sel = new Select("job_sel", Job::getJobOptions(), ['useEmpty' => true, 'emptyText' => 'Please choose...']); $job_sel->setLabel('Run every:'); $this->add($job_sel); $job = new Text("job"); $job->setLabel('Custom def.:'); $this->add($job); $status = new Check('status', ['value' => 1, 'style' => 'min-width: auto']); $status->setLabel('Is active:'); $status->setDefault(1); $this->add($status); //$this->setCsrf(); }
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); }
public function getParents() { if ($this->parents) { return $this->parents; } $category = new Models\Category(); $categories = $category->find(array("limit" => 100)); $category = $this->getModel(); if ($category->parents) { $values = array(); foreach ($category->parents as $_cate) { $values[] = $_cate->id; } foreach ($categories as $key => $item) { $check = new Check('parents[]', array('value' => $item->id)); if (in_array($item->id, $values)) { $check->setDefault($item->id); } $check->setLabel($item->categoryName); $this->parents[] = $check; } } return $this->parents; }
public function getCategories() { if ($this->categories) { return $this->categories; } $category = new Models\Category(); $categories = $category->find(array("order" => "id DESC", "limit" => 100)); $post = $this->getModel(); $values = array(); if ($post && $post->categories) { foreach ($post->categories as $categoryitem) { $values[] = $categoryitem->id; } } foreach ($categories as $key => $item) { $check = new Check('categories[]', array('value' => $item->id)); if (in_array($item->id, $values)) { $check->setDefault($item->id); } $check->setLabel($item->categoryName); $this->categories[] = $check; } return $this->categories; }