Esempio 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);
 }
Esempio n. 2
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);
 }