function __construct(IComponentContainer $parent = NULL, $name = NULL) { NForm::extensionMethod('addDateTimePicker', 'MyForm::Form_addDateTimePicker'); parent::__construct($parent, $name); $t = NEnvironment::getApplication()->getPresenter()->getService('translator'); $t->setLang(NEnvironment::getApplication()->getPresenter()->lang); $this->setTranslator($t); NFormContainer::extensionMethod('NFormContainer::addRecaptcha', array('reCAPTCHA', 'addRecaptcha')); }
private function baseForm() { $f = new MyForm(); $renderer = $f->getRenderer(); $renderer->wrappers['controls']['container'] = NHtml::el('table')->addClass('standard'); $f->addGroup(_('Pridanie produktu'))->setOption('container', NHtml::el('div')->class('groupHolder')->id('groupHolderMain')); $f->getElementPrototype()->class('long_input'); $langs = Setting::getLangs(); foreach ($langs as $l) { $f->addGroup(count($langs) == 1 ? '' : $l['name'])->setOption('container', 'fieldset class=lang_fieldset id=lang_' . $l['iso']); $f->addText('name' . CategoryFormControl::$_separator . $l['iso'], 'Názov')->addRule(NForm::FILLED, _('Nazov musí byť vyplnený.')); $f->addTextArea('description' . CategoryFormControl::$_separator . $l['iso'], _('Popis')); $f->addTextArea('long_description' . CategoryFormControl::$_separator . $l['iso'], _('Dlhý popis')); // $f->addTextArea('referencies' . CategoryFormControl::$_separator . $l['iso'], _('Referencie') ); $f->addText('link_rewrite' . CategoryFormControl::$_separator . $l['iso'], _('URL link')); $f->addText('meta_title' . CategoryFormControl::$_separator . $l['iso'], _('Titulok')); // $f->addText('meta_keywords' . CategoryFormControl::$_separator . $l['iso'], _('Kľúčové slová') ); $f->addText('meta_description' . CategoryFormControl::$_separator . $l['iso'], _('Meta popis')); } $f->addGroup(); // $f->addSelect('id_product_supplier', // 'Výrobca', // array(NULL => '-------') + SupplierModel::getFluent()->fetchPairs('id_product_supplier', 'name') // ); //->add(NHtml::el('span')->setHtml('palo')); // $f->addText('price', _('Cena')) // ->addRule(NForm::FLOAT, _('Cena musí byť číslo.')); // $f->addText('code', _('Kód tovaru')); // $f->addText('weight', _('Váha')); // $f->addText('packing', _('Balenie')); // $f->addText('unit_of_measure', _('Merná jednotka')); // $f['price']->getControlPrototype()->addClass('short_text'); // // $f->addText('pack_type', 'Druh balenia'); // $f['pack_type']->getControlPrototype()->addClass('short_text'); // // // $f->addText('color', 'Farba'); // $f['color']->getControlPrototype()->addClass('short_text'); // // $f->addText('capacity', 'Objem'); // $f['capacity']->getControlPrototype()->addClass('short_text'); // // $f->addText('product_number', 'Číslo produktu'); // $f['product_number']->getControlPrototype()->addClass('short_text'); // // // $f->addText('pack_count', 'Balenie'); // $f['pack_count']->getControlPrototype()->addClass('short_text'); //$f->addText('ean13', 'Kód')->getControlPrototype()->addClass('short_text'); $vat = VatModel::init(); if ($this->context->parameters['SHOW_TAX_FOR_PRODUCT'] == 1) { $f->addRadioList('id_vat', _('DPH %'), $vat->getFluent()->fetchPairs('id_vat', 'name'))->setDefaultValue($vat->getDefault()); } else { $f->addHidden('id_vat')->setDefaultValue($vat->getDefault()); } // // $f->addText('delivery_date', _('Dodacia lehota (dni)')) // ->getControlPrototype()->addClass('short_text'); $f->addRadioList('active', 'Aktívny', array(1 => 'Povolený', 0 => 'Zakázaný'))->setDefaultValue(1); // $f->addRadioList('available', 'Dostupný do 48 hodín', array(1 => 'áno', 0 => 'nie'))->setDefaultValue(1); // $f->addText('weight', 'Hmotnosť (kg)')->getControlPrototype()->class = 'small'; // $f->addCheckbox('our_tip', 'Najpredávanejší'); //$f->addCheckbox('sale', 'Výpredaj'); $f->addCheckbox('home', 'Zobraziť na úvode'); $f->addCheckbox('our_tip', 'TOP'); $f->addCheckbox('news', 'Novinka'); $f->addCheckbox('sale', 'Akcia'); $f->addText('sale_percent', 'Zľava %')->getControlPrototype()->class = 'small'; $f->addGroup('Kategórie'); //->setOption('container', NHtml::el('div')->class('groupHolder')->id('categoryHolderOptions')); NForm::extensionMethod('NForm::addCBTree', array('CBTree', 'addCBTree')); $tree = new TreeView(); $id_product = $this->getParam('id'); $tree->primaryKey = 'id_category'; $tree->parentColumn = 'id_parent'; $tree->useAjax = true; $tree->mode = 1; $tree->addLink(null, 'name', 'id', true, $this->presenter); $tree->dataSource = CategoryModel::getTreeCheckProduct($id_product)->where("id_lang = %i", $this->getPresenter()->id_lang); $f->addCBTree('id_categories', _('Kategórie'), $tree)->initialState = 'expand'; $f->addGroup('Príslušenstvo'); $product_alternative = ProductModel::getFluent($this->id_lang)->where('1=1 %if', $id_product, 'AND id_product != %i', $id_product, "%end")->fetchPairs("id_product", 'name'); $f['product_alternative'] = new MultiSelectDualList('Príslušenstvo', $product_alternative); $templateGroupParams = $this->getService('ProductTemplateGroupModel')->fetchPairs(); //ak je iba jedna, nezobrazi sa vyber if (count($templateGroupParams) > 1) { $f->addSelect('id_product_template_group', 'Skupina parametrov', $templateGroupParams); } else { $f->addHidden('id_product_template_group')->setDefaultValue(key($templateGroupParams)); } $f->addHidden('id_product'); $f->addGroup('')->setOption('container', NHtml::el('div')->class('button')); return $f; }