Ejemplo n.º 1
0
 private static function assignForm($category, $errors)
 {
     $form = new TemplateForm();
     $form->addTextField('name', 'Название', $category->name, isset($errors['name']) ? $errors['name'] : null, true);
     $form->addCheckboxField('active', 'Вкл/Выкл', $category->active);
     $form->classes = 'center-form';
     self::templateVar('content', $form);
 }
Ejemplo n.º 2
0
 public function actionNew()
 {
     $model = new TemplateForm();
     if (isset($_POST["TemplateForm"])) {
         $model->attributes = $_POST["TemplateForm"];
         if ($model->save()) {
             $this->flash('Data Berhasil Disimpan');
             $this->redirect(['index']);
         }
     }
     $this->renderForm("TemplateForm", $model);
 }
Ejemplo n.º 3
0
 public function actionInsertRelModel()
 {
     $model = new TemplateForm();
     $posted = false;
     if (isset($_POST["TemplateForm"])) {
         $model->attributes = $_POST["TemplateForm"];
         if ($model->save()) {
             $posted = true;
         }
     }
     $this->renderForm("TemplateForm", $model, ['inserted' => $model->{$model->tableSchema->primaryKey}, 'posted' => $posted], ['layout' => '//layouts/blank']);
 }
Ejemplo n.º 4
0
 function editAction()
 {
     $this->view->title = 'Edit Template';
     $form = new TemplateForm(array('legend' => $this->view->title));
     $form->submit->setLabel('Update');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $form_data = $this->_request->getPost();
         if ($form->isValid($form_data)) {
             $templates = new Templates();
             $id = $form->getValue('id');
             $row = $templates->fetchRow('id=' . $id);
             $row->name = $form->getValue('name');
             $row->width = $form->getValue('width');
             $row->height = $form->getValue('height');
             $row->save();
             $this->saveData($id);
             $this->_redirect('/template/view/id/' . $id);
         } else {
             $form->populate($form_data);
         }
     } else {
         $id = $this->_request->getParam('id');
         if ($id > 0) {
             $templates = new Templates();
             $row = $templates->fetchRow('id=' . $id);
             $form->populate($row->toArray());
         }
     }
     $this->_helper->viewRenderer('form');
 }
Ejemplo n.º 5
0
 public function actionInsertRelModel($id = "")
 {
     $model = new TemplateForm();
     $posted = false;
     if ($id != "") {
         $model->foreignKey = $id;
     } else {
         $id = 999;
     }
     if (isset($_POST["TemplateForm"])) {
         $model->attributes = $_POST["TemplateForm"];
         $model->foreignKey = $id;
         if ($model->insertMethod()) {
             $posted = true;
         }
     }
     $this->renderForm("TemplateForm", $model, ['inserted' => true, 'posted' => $posted], ['layout' => '//layouts/blank']);
 }
Ejemplo n.º 6
0
 private static function assignForm($product, $errors)
 {
     $categories = Database::getTable("\n            SELECT\n                `c`.`id` AS `value`,\n                `cl`.`name` AS `text`\n            FROM `category` AS `c`\n            LEFT JOIN `category_lang` AS `cl` ON `cl`.`id_object` = `c`.`id`\n            WHERE `c`.`active` = 1 AND `cl`.`id_lang` = 1\n            ORDER BY `cl`.`name`\n        ");
     $brands = Database::getTable("\n            SELECT\n                `id` AS `value`,\n                `name` AS `text`\n            FROM `brand`\n            WHERE `active` = 1\n            ORDER BY `name`\n        ");
     $form = new TemplateForm();
     $form->addTextField('name', 'Название', $product->name, isset($errors['name']) ? $errors['name'] : null, true);
     $form->addTextField('articul', 'Артикул', $product->articul, isset($errors['articul']) ? $errors['articul'] : null);
     $form->addTextField('price', 'Цена', $product->price, isset($errors['price']) ? $errors['price'] : null);
     $form->addSelectField('id_category', 'Категория', $categories, $product->id_category, isset($errors['id_category']) ? $errors['id_category'] : null, 'Выберите категорию');
     $form->addSelectField('id_brand', 'Производитель', $brands, $product->id_brand, isset($errors['id_brand']) ? $errors['id_brand'] : null, 'Выберите произвотеля');
     $form->addTextareaField('description', 'Описание', $product->description, null, true, true);
     $form->addCheckboxField('active', 'Вкл/Выкл', $product->active);
     if ($product->getId()) {
         $list = new TemplateList();
         $list->fields = array('file' => array('type' => 'image', 'title' => '', 'directory' => 'products', 'size' => '85x84'));
         $list->itemActions = array('down-image' => array('hint' => 'Опустить', 'icon' => 'down', 'controller' => 'AdminProducts'), 'up-image' => array('hint' => 'Поднять', 'icon' => 'up', 'controller' => 'AdminProducts'), 'delete-image' => array('hint' => 'Удалить', 'icon' => 'delete', 'controller' => 'AdminProducts'));
         $list->items = $product->images;
         $form->addUploaderField('image', 'Добавить картинку', App::getLink('AdminProducts', array('action' => 'new-image')), '*.jpg;*.jpeg;*.png', 'Изображения', '3MB', array('product' => $product->getId()), $list);
     } else {
         $form->addUploaderField('image', 'Добавить картинку', App::getLink('AdminProducts', array('action' => 'new-image')), '*.jpg;*.jpeg;*.png', 'Изображения', '3MB');
     }
     $form->classes = 'center-form';
     self::templateVar('content', $form);
 }