protected function createComponentAddEdit($name) { $roles[0] = ' '; $mroles = new RolesModel(); $rows = $mroles->getTreeValues(); foreach ($rows as $key => $row) { // function array_merge does't work correctly with integer indexes // manual array merge $roles[$key] = $row; } $form = new NAppForm($this, $name); $renderer = $form->getRenderer(); $renderer->wrappers['label']['suffix'] = ':'; //$form->addGroup('Add'); $form->addText('name', 'Name', 30)->addRule(NForm::FILLED, 'You have to fill name.')->getControlPrototype()->onChange("create_key()"); $form->addText('key_name', 'Key', 30)->addRule(NForm::FILLED, 'You have to fill key.'); $form->addSelect('parent_id', 'Parent', $roles, 15); $form->addTextArea('comment', 'Comment', 40, 4)->addRule(NForm::MAX_LENGTH, 'Comment must be at least %d characters.', 250); if ($this->getAction() == 'add') { $form->addSubmit('add', 'Add'); } else { $form->addSubmit('edit', 'Edit'); } $form->onSuccess[] = array($this, 'addEditOnFormSubmitted'); }
protected function createComponentAddNews() { $form = new NAppForm(); $form->addText('title', 'Titulek:')->addRule(NForm::FILLED, 'Vyplňtě prosím titulek novinky.'); $form->addTextArea('content', 'Obsah:', 40, 20)->addRule(NForm::FILLED, 'Vyplňte prosím obsah novinky.'); $form->addCheckbox('active', 'Aktivní novinka'); $form->addSubmit('addnews', 'Uložit'); // Set control class $form['title']->getControlPrototype()->class('s100'); $form['content']->getControlPrototype()->class('s100'); $form->onSubmit[] = callback($this, 'newsFormSubmited'); return $form; }
/** * Create contact form controler * @return NAppForm */ public function createComponentPopForm() { $id = (int) $this->getParam('id'); $form = new NAppForm(); $form->addTextArea('body', 'Zpráva:', 40, 10)->addRule(NForm::FILLED, 'Vyplňte prosím obsah zprávy.'); $form->addText('contact', 'Kontakt na Vás (e-mail nebo telefon):')->addRule(NForm::FILLED, 'Nezapomeňte prosím uvést na sebe kontakt.'); $form->addImage('popsend', NEnvironment::getVariable('baseUri') . 'layout/img/form-send.jpg', 'Odeslat'); $form->addHidden('id', $id); $form->getElementPrototype()->class('ajax'); $form['body']->getControlPrototype()->class('s100 h140px'); $form['contact']->getControlPrototype()->class('s100'); $form->onSubmit[] = callback($this, 'popFormSubmited'); return $form; }
function createComponentCommentAnswerForm() { $form = new NAppForm(); $form->addProtection('Bohužial Váš formulár expiroval. Prosím odošlite formulár znovu.', 360); $form->addText('name', 'Meno: ')->addRule(NForm::FILLED, 'Meno musí byť vyplnené.')->getLabelPrototype()->addId('commentAnswerFormNameLabel'); $form->addTextArea('text', 'Text: ')->addRule(NForm::FILLED, 'Text musí byť vyplnený.')->getLabelPrototype()->addId('commentAnswerFormTextLabel'); $form->addSubmit('submitComment', 'Pridať'); // ->onClick[] = 'processCommentForm'); $form->addHidden('id_node'); $form->addHidden('comment_parent'); // ->setValue($id_node); $form->onSuccess[] = array($this, 'processCommentForm'); // $form->setDefaults(array('name'=>'palo', 'text'=>'tessslks isnks')); return $form; }
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; }
protected function createComponentAddEdit($name) { $form = new NAppForm($this, $name); $renderer = $form->getRenderer(); $renderer->wrappers['label']['suffix'] = ':'; if (ACL_PROG_MODE) { $form->addText('name', 'Name', 30)->addRule(NForm::FILLED, 'You have to fill name.')->getControlPrototype()->onChange("create_key()"); } else { $form->addText('name', 'Name', 30)->addRule(NForm::FILLED, 'You have to fill name.'); } //$form->addGroup('Edit'); $form->addText('key_name', 'Key', 30)->setDisabled(ACL_PROG_MODE ? false : true); $form->addTextArea('comment', 'Comment', 40, 4)->addRule(NForm::MAX_LENGTH, 'Comment must be at least %d characters.', 250); if ($this->getAction() == 'add') { $form->addSubmit('add', 'Add'); } else { $form->addSubmit('edit', 'Edit'); } $form->onSuccess[] = array($this, 'addEditOnFormSubmitted'); }