Esempio n. 1
0
 function createComponentBaseForm()
 {
     //	NForm::extensionMethod('NForm::addCBTree', array('CBTree', 'addCBTree'));
     //
     //	$tree = new TreeView;
     //
     //	$tree->primaryKey = 'id_category';
     //	$tree->parentColumn = 'id_parent';
     //	$tree->useAjax = false;
     //	$tree->addLink(null, 'name', 'id', true, $this->presenter);
     //	$tree->dataSource = CategoryModel::getDatasource()->where("id_lang = %i",$this->getPresenter()->id_lang);
     //$form->addCBTree('ctree', _('Kategórie'), $tree);
     $form = new NAppForm();
     $renderer = $form->getRenderer();
     // budeme generovat formulář jako definiční seznam
     $renderer->wrappers['controls']['container'] = NHtml::el('table')->addClass('standard');
     $langs = Setting::getLangs();
     foreach ($langs as $k => $lang) {
         $form->addGroup($lang['name'])->setOption('container', 'fieldset class=lang_fieldset id=lang_' . $lang['iso']);
         $form->addText('name' . self::$_separator . $lang['iso'], _('Názov'))->addRule(NFORM::FILLED, 'Názov ' . $lang['iso'] . ' musí byť vyplnený.');
         $form->addTextArea('description' . self::$_separator . $lang['iso'], 'Popis');
         $form->addText('link_rewrite' . self::$_separator . $lang['iso'], 'URL link')->setDisabled();
         $form->addText('meta_title' . self::$_separator . $lang['iso'], 'Titulok');
         //	    $form->addText('meta_keywords'.self::$_separator.$lang['iso'], 'Kľúčové slová');
         $form->addText('meta_description' . self::$_separator . $lang['iso'], 'Meta popis');
     }
     //$form->addText('icon','Názov ikony');
     $form->addCheckbox('show_on_bottom', 'Zobraziť v spodnej časti');
     $form->addGroup('');
     $form->addHidden('id_category');
     $c = new CategoryModel($this->getPresenter()->id_lang);
     $select = array('' => 'root');
     /*
      * todo dorobit, aby sa nedala vybrat samu seba categoria
      */
     $c->generateTreeToSelect($select, NULL, NULL);
     $form->addSelect('id_parent', 'Rodič', $select);
     //		->addRule(NForm::FILLED, _('Rodič musí byť vyplnený.') );
     $form->addSelect('active', 'Aktívny', array(1 => 'Povolený', 0 => 'Zakázaný'));
     $form->onSuccess[] = array($this, 'categoryAction');
     return $form;
 }