function createComponentForm($name) { $form = new MyForm($this, $name); $form->addText('name', 'Meno:')->addRule(NForm::FILLED, 'Meno a priezvisko musia byť vyplnené.'); $form->addText('surname', 'Priezvisko:')->addRule(NForm::FILLED, 'Meno a priezvisko musia byť vyplnené.'); $form->addText('company', 'Firma:'); $form->addText('email', 'Email:'); $form->addText('tel', 'Telefón:'); $form->addTextarea('text', 'Textová správa:')->addRule(NForm::FILLED, 'Správa musí byť vyplnená.'); $form->addSubmit('btn_form', 'Odoslať správu'); $form->addHidden('id_node'); $form->onSuccess[] = callback($this, 'handleSend'); return $form; }
function createComponent($name) { switch ($name) { case 'order': $orderSession = $this->getSession(); $f = new MyForm(); $f->getElementPrototype()->class = 'ajax'; $f->addSelect('order_select', 'Zoradenie podľa: ', $this->getOrderFilterArray())->getControlPrototype()->class = 'orderBy'; $f->onSuccess[] = array($this, 'handleChangeOrder'); $f->setDefaults(array('order_select' => $orderSession['order'])); return $f; break; default: return parent::createComponent($name); break; } }
protected function createComponent($name) { switch ($name) { default: parent::createComponent($name); break; case 'newsletterform': $form = new MyForm(); $form->getElementPrototype()->class = 'ajax'; $form->addText('email', 'Váš email')->addRule(NAPPFORM::FILLED, 'Email musí byť vyplnený.')->addRule(NAPPFORM::EMAIL, 'Zadaný email nieje v správnom tvare.'); // $form['email']->getLabelPrototype()->class = 'inlined'; // $form['email']->getLabelPrototype()->id = 'emaillabel'; $form->addSubmit('sendnewsletter', 'Ok'); $form->onSuccess[] = array($this, 'sendToEmailRegisterToNewsletter'); return $form; break; } }
function createComponentForm($name) { $f = new MyForm(); $f->addText('name', 'Názov')->addRule(NForm::FILLED, 'Názov musí byť vyplnený'); $f->addText('price', 'Cena')->addRule(NForm::FILLED, 'Cena musí byť vyplená')->addRule(NForm::FLOAT, 'Cena musí byť číslo'); $f->addTextArea('description', 'Popis')->getControlPrototype()->class = 'long'; $f->addHidden($this->model->getTableIdName()); $f->addSubmit('btn', 'Uložiť')->getControlPrototype()->class = 'submit'; $f->onSuccess[] = array($this, 'handleSave'); return $f; }
function createComponentForm($name) { $f = new MyForm(); $f->addText('key', 'Názov')->addRule(NForm::FILLED, 'Názov musí byť vyplnený'); $f->addTextArea('text', 'Popis')->getControlPrototype()->class = 'long'; $f->addHidden('id_helps'); $f->addSubmit('btn', 'Uložiť')->getControlPrototype()->class = 'submit'; $f->onSuccess[] = array($this, 'handleSave'); return $f; }
function createComponentPaymentAndDelivetyForm($name) { $f = new MyForm(); $f->addRadioList('id_delivery', 'Doprava', $this->getService('Delivery')->fetchPairs('name'))->addRule(NForm::FILLED, 'Musíte vybrať dopravu'); $f->addRadioList('id_payment', 'Platby', $this->getService('Payment')->fetchPairs('name'))->addRule(NForm::FILLED, 'Musíte vybrať spôsob platby.'); $f->addSubmit('btn', 'Pokračovať'); $f->onSuccess[] = array($this, 'handleSavePaymentAndDelivery'); $f->setDefaults(array('id_delivery' => $this->getService('Delivery')->getDefault(), 'id_payment' => $this->getService('Payment')->getDefault())); return $f; }
function createComponentForm($name) { $f = new MyForm(); $f->addText('name', 'Názov')->addRule(NForm::FILLED, 'Názov musí byť vyplnená'); $f->addText('value', 'Hodnota')->addRule(NForm::FILLED, 'Hodnota musí byť vyplnená'); $f->addSelect('is_default', 'Prednastavená?', array(0 => 'nie', 1 => 'áno')); $f->addSubmit('btn', 'Pridať'); $f->onSuccess[] = array($this, 'handleSave'); return $f; }
function createComponentWidgetForm($name) { $f = new MyForm(); $f->addText('identifier', 'Identifikátor')->addRule(NForm::FILLED, 'Identifikátor musí byť vyplnený'); $f->addText('name', 'Názov'); $f->addTextarea('template', 'Šablóna')->getControlPrototype()->class = 'long'; $f->addHidden('id_widget'); $f->addContainer('params'); $f->addSubmit('save', 'Uložiť'); $f->addSubmit('addNewParam', 'Pridať parameter')->onClick[] = callback($this, 'handleAddNewParam'); $f->onSuccess[] = array($this, 'handleSaveForm'); $values = (array) $this->getService('Widget')->get($this->getParam('id')); foreach ($values['params'] as $k => $p) { $container = $f['params']->addContainer($k); $container->addText('name', 'Názov'); $container->addText('value', 'Hodnota'); //->setDefaultValue(array($p['value'])); $container->setDefaults((array) $p); } // unset($values['params']); return $f; }
protected function createComponentAddToCartForm() { $presenter = $this; return new NMultiplier(function ($id) use($presenter) { /* @var $f NForm */ $f = new MyForm(); $f->getElementPrototype()->class = 'ajax'; $f->addText('count', 'Počet')->addRule(NForm::FILLED, 'Počet musí byť vyplnený.')->addRule(NForm::INTEGER, 'Musíte zadať číslo.'); $f->addSubmit('btn', 'DO KOŠÍKA'); $f->addHidden('id', $id); $f->onSuccess[] = array($presenter, 'handleAddToCart'); $f->setDefaults(array('count' => 1)); return $f; }); }
function createComponentRequestBtn($name) { $f = new MyForm(); $f->getElementPrototype()->class = 'ajax'; $f->addText('keywords', 'Klúčové slovo')->addRule(NForm::FILLED, 'Klúčové slovo musí byť vyplnené')->addRule(NForm::MIN_LENGTH, "Klúčové slovo musí byť dlhšie", 3); $count = array(); for ($i = 1; $i < 30; $i++) { if (!($i % 5)) { $count[$i] = $i; } } $f->addSelect('google_num_result', 'Počet stránok', $count); $f->addSubmit('btn', 'Zobraziť príbuzné klúčové slová'); $f->onSuccess[] = array($this, 'handleShowKeywords'); return $f; }
function __construct(IComponentContainer $parent = NULL, $name = NULL) { parent::__construct($parent, $name); $this->builtForm(); }
protected function createComponentSettingForm($name) { $article = $this->getService('Article'); $f = new MyForm(); $f->addGroup('Nastavenie eshopu'); $f->addSelect('SHOP_ENABLE', 'Zapnúť obchod', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené'); $f->addSelect('SHOW_PRICE_WITH_TAX', 'Cena sa bude zadávať i zobrazovať s DPH?', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené'); $f->addSelect('SHOW_TAX_FOR_PRODUCT', 'Zobraziť priradenie dane pri produkte', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené'); // $f->addSelect('SHOW_PRICE_WITH_DPH', 'Cena sa zobraz s DPH', array(0=>'nie', 1=>'áno')) // ->addRule( NForm::FILLED, 'Musí byť vyplené'); $f->addSelect('CONDITIONS_CMS_ID', 'Obchodné podmienky, použitie CMS stránky', $article->getFluent()->fetchPairs('id_node', 'title')); $f->addTextArea('footer_for_emails', 'Pätička pre emaili')->getControlPrototype()->style = "width:700px;"; $f->addGroup('Heureka'); $f->addSelect('HEUREKA__ENABLE', 'Spustiť heureku', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené'); $f->addText('HEUREKA__API_KEY', 'API KEY'); $f->addGroup('Facebook'); $f->addSelect('FACEBOOK__AUTH_ENABLE', 'Povoliť Facebook prihlasovanie', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené'); //twitter.consumer_key = JD4NBeGvlkEomwmaYYlIQ //twitter.consumer_secret = WgRwndqR3oA6hShLk43mnQVTpcJvvY9Lmsfe45WNXw // //google.client_id = 924141147825.apps.googleusercontent.com //google.client_secret = G1SSmJ0efgD69eKP43D04FEd //google.redirect_url = "http://www.propagacnepredmety.sk/google-account/log-in/" $f->addText('FACEBOOK__appId', 'appId'); $f->addText('FACEBOOK__secret', 'secret'); $f->addGroup('Google Account'); $f->addSelect('GOOGLE__AUTH_ENABLE', 'Povoliť Google prihlasovanie', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené'); $f->addText('GOOGLE__client_id', 'client_id'); $f->addText('GOOGLE__client_secret', 'client_secret'); $f->addText('GOOGLE__application_name', 'application_name'); $f->addText('GOOGLE__redirect_url', 'redirect_url'); $f->addGroup('Google Analytics'); $f->addText('GOOGLE_ANALYTICS__ID', 'ID'); $f->addGroup('Doprava'); // $f->addSelect('DELIVERY_IS_WITH_TAX', 'Doprava je už s danou?', array(0=>'nie', 1=>'áno')) // ->addRule( NForm::FILLED, 'Musí byť vyplené'); $vat = VatModel::init(); $f->addSelect('DELIVERY_TAX', 'Dan na dopravu?', $vat->getFluent()->fetchPairs('value', 'name'))->addRule(NForm::FILLED, 'Musí byť vyplené'); $f->addGroup('Platby'); $vat = VatModel::init(); $f->addSelect('PAYMENT_TAX', 'Dan na platbu?', $vat->getFluent()->fetchPairs('value', 'name'))->addRule(NForm::FILLED, 'Musí byť vyplené'); $f->addGroup(); $f->addSubmit('btn', 'Uložiť'); $f->onSuccess[] = array($this, 'handleSaveSetting'); $f->setDefaults($this->getService('Setting')->fetchPairs()); return $f; }
function createComponent($name) { switch ($name) { // case 'addForm': // $form = $this->baseForm(); // $form->addSubmit('btn', 'Pridať'); //// $values['product_alternative'] = ProductModel::getFluent($this->id_lang)->where('id_category = 5')->fetchPairs("id_product",'id_product'); // //poziadavka klienta - zobrat vsetky produkty z doplnkov // // // $form->setDefaults( array('id_product_template_group'=>$this->getService('ProductTemplateGroupModel')->getIdDefaultTemplate()) ); // // // $form->onSuccess[] = callback($this, 'add'); // return $form; // break; case 'editForm': $id_product = $this->getPresenter()->getParam('id'); $form = $this->baseForm(); $form['id_product']->setValue($id_product); $values = array(); //Titulok - doplnit categoria+ nazov produktu //Kľúčové slová - //Meta popis - doplnit categoria+ nazov produktu + Výkon + Dĺžka Horenia foreach ($this->template->langs as $l) { $val = ProductModel::get($id_product, $l['id_lang']); // ziste ktore komponenty maju jazykovu mutaciu $controls_for_lang = array(); foreach ($form->getComponents() as $control) { if (strpos($control->getName(), CategoryFormControl::$_separator)) { if (strpos($control->getName(), CategoryFormControl::$_separator . $l['iso'])) { list($val_key) = explode(CategoryFormControl::$_separator . $l['iso'], $control->getName()); $values += array($control->getName() => $val[$val_key]); } } else { if (isset($val[$control->getName()])) { $values += array($control->getName() => $val[$control->getName()]); } } } } //print_r(ProductModel::getProductAlternative($id_product));exit; $values['product_alternative'] = ProductModel::getProductAlternative($id_product); // vyriesenie categorii //nacitanie prveho parametru - iba pre jednoparametrove produkty $param = (array) dibi::fetch("SELECT * FROM [product_param] WHERE id_product = %i", $id_product); $form->setDefaults(array_merge($param, $values)); $form->addSubmit('btn_save_and_stay', 'Upraviť a zostať tu'); $form->addSubmit('btn_save', 'Upraviť'); $form->onSuccess[] = callback($this, 'save'); return $form; break; /* * generator */ /* * generator */ case 'generatorForm': //ProductModel::repairMinPrice(); NFormContainer::extensionMethod('NFormContainer::addCheckboxList', array('CheckboxList', 'addCheckboxList')); $sizes = dibi::query("SELECT size FROM [product_param] WHERE size !='' GROUP BY size")->fetchPairs('size', 'size'); $colors = dibi::query("SELECT color FROM [product_param] WHERE color !='' GROUP BY color")->fetchPairs('color', 'color'); $materials = dibi::query("SELECT material FROM [product_param] WHERE material !='' GROUP BY material")->fetchPairs('material', 'material'); $f = new MyForm(); // $f->getElementPrototype()->addClass('ajax'); $renderer = $f->getRenderer(); $renderer->wrappers['controls']['container'] = NHtml::el('div')->addClass('container'); $renderer->wrappers['pair']['container'] = NHtml::el('div')->addClass('pair-container'); $renderer->wrappers['label']['container'] = NHtml::el('h3'); $renderer->wrappers['control']['container'] = NHtml::el('div')->addClass('input-container'); // usort($sizes, 'EshopProductControl::cmp'); $f->addCheckboxList('size', 'Veľkosť', $sizes); $f->addCheckboxList('color', 'Farba', $colors); $f->addCheckboxList('material', 'Material', $materials); //ak je pridavanie a neexistuje id $f->addHidden('id_product', $this->getParam('id')); // // // $renderer = $f->getRenderer(); // $renderer->wrappers['label']['container'] = NULL; // // //ziskaj vsetky mozne velkosti // $sizes = dibi::fetchAll("SELECT size FROM [product_param] GROUP BY size"); // $f->addGroup('Veľkosť'); // foreach($sizes as $k=>$size){ // $f->addCheckbox('size_'.$k, $size['size']); // } // // //ziskaj vsetky mozne farby // $colors = dibi::fetchAll("SELECT color FROM [product_param] GROUP BY color"); // $f->addGroup('Farba'); // foreach($colors as $k=>$color){ // $f->addCheckbox('color_'.$k, $color['color']); // } // // //ziskaj vsetky mozne material // $materials = dibi::fetchAll("SELECT material FROM [product_param] GROUP BY material"); // $f->addGroup('Material'); // foreach($materials as $k=>$material){ // $f->addCheckbox('material_'.$k, $material['material']); // } $f->addGroup()->setOption('container', 'fieldset class=clear'); $f->addSubmit('btn_generate', 'Generovať'); $f->onSuccess[] = array($this, 'handleAddGeneratedParam'); return $f; break; case 'productParams': // $d = ProductModel::getProductParamDatasource( $this->getParam('id'))->fetchAll(); $id_product = $this->getParam('id'); $grid = new Tabella(ProductModel::getProductParamDatasource($id_product), array('sorting' => 'asc', 'order' => 'sequence', 'id_table' => 'id_product_param', 'limit' => 50, "onSubmit" => function ($post) { // print_r($post);exit; ProductModel::setProductParamValue($post, $post['id_product_param']); }, "onDelete" => function ($id) { ProductModel::deleteProductParamValue($id); })); $el = NHtml::el("div"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyParam!', array('id_product' => $id_product)))->addClass('addIcon ajax')); $grid->addColumn($el, 'sequence', array('width' => 20, 'filter' => NULL, "editable" => true)); //vytiahnutie template_group pre produkt - ake bude mat parametre if ($id_product) { $id_product_template_group = ProductModel::getFluent(1, false, false)->removeClause('select')->select('id_product_template_group')->where('id_product = %i', $id_product)->fetchSingle(); } else { //ak je id_product NULL jedna sa pridavanie produktu if ($id_product == NULL and $this->getParam('id_product_template_group') != NULL) { $id_product_template_group = $this->getParam('id_product_template_group'); } else { $id_product_template_group = $this->getService('ProductTemplateGroupModel')->getIdDefaultTemplate(); } } $params = $this->getService('ProductTemplateGroupModel')->fetchAssocAllParam($id_product_template_group); foreach ($params as $p) { if ($p['checked']) { $grid->addColumn($this->getService('translator')->translate($p['row_name']), $p['row_name'], array("width" => 50, "editable" => true)); } } $grid->addColumn("Cena", "price", array("width" => 100, "editable" => true)); // _repairPriceForView // // // $grid->addColumn( "Na sklade", "stock", array( "width" => 50, "editable" => true ) ); //// $grid->addColumn( "Farba", "color", array( "width" => 100, "editable" => true ) ); //// $grid->addColumn( "Veľkosť", "size", array( "width" => 100, "editable" => true ) ); //// $grid->addColumn( "Material", "material", array( "width" => 100, "editable" => true ) ); // $grid->addColumn( "Napojenie", "connection", array( "width" => 100, "editable" => true ) ); // $grid->addColumn( "Cena", "price", array( "width" => 100, "editable" => true ) ); $grid->addColumn("", "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) { $el = NHtml::el("td"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteProductParam!', array('id_product_param' => $row->id_product_param)))->addClass('deleteIcon ajax')); return $el; })); $this->addComponent($grid, $name); break; case 'pictogram': $p = new PictogramControl($this, $name); return $p; break; case 'keyword': return new KeywordControl(); break; case 'ajaxtest': return new AjaxTextControl(); break; default: return parent::createComponent($name); break; } }
function createComponent($name) { switch ($name) { /* * newsletterTabella */ case 'newsletterTabella': $grid = new Tabella(NewsletterModel::getFluent()->toDataSource(), array('sorting' => 'desc', 'order' => 'adddate', 'id_table' => 'id', 'limit' => 100, 'onSuccess' => function ($values) { NewsletterModel::edit($values, $values['id_newsletter_emails']); }, 'onDelete' => function ($id_newsletter_emails) { NewsletterModel::delete($id_newsletter_emails); })); $el = NHtml::el("div"); $session = NEnvironment::getSession('checked_emails'); $grid->addColumn($el, "", array("editable" => false, 'filter' => false, "width" => 20, "renderer" => function ($row) use($session) { $el = NHtml::el("td"); $checked = isset($session->emails[$row['id_newsletter_emails']]) ? 'checked="checked"' : ''; $el->add('<input class="checked_emails" type="checkbox" name="se[]" value="' . $row['id_newsletter_emails'] . '" ' . $checked . '/>'); return $el; })); $grid->addColumn("Id", "id_newsletter_emails", array("width" => 30, 'editable' => false)); $grid->addColumn("Email", "email", array("width" => 50, 'editable' => false)); // $grid->addColumn( "Popis", "description", array( 'editable'=>true ) ); $grid->addColumn("Dátum registrácie ", "adddate", array("width" => 100)); /*$grid->addColumn( "Aktívny", "active", array( "width" => 50, 'type'=> Tabella::SELECT, "editable" => true, "filter" => array( 1=>'áno', 0=>'nie'), 'renderer' => function($row){ $active = ($row['active'] == 1)?'áno':'nie'; $el = NHtml::el( "td" )->setHtml($active); return $el; } ) ); $grid->addColumn("", "", array( "width" => 30, 'filter'=>NULL, "options" => '', "renderer" => function( $row ) { $el = NHtml::el( "td" ); $el->add( NHtml::el( 'a' )->href( NEnvironment::getApplication()->getPresenter()->link( 'deleteEmail!' , array('id'=>$row->id_newsletter_emails)) )->addClass( 'deleteIcon' ) ); $span = NHtml::el('span'); $el->add($span); return $el; } ) ); */ $this->addComponent($grid, $name); break; /* * newslette text */ /* * newslette text */ case 'newsletterTextForm': $last_newsletter = dibi::fetch("SELECT * FROM [newsletter_sended_msg] ORDER BY [date] DESC LIMIT 1"); $f = new MyForm($this, $name); $f->addText('subject', 'Predmet')->addRule(NForm::FILLED, 'Predmet musí byť vyplnený.'); $f->addTextArea('text', ''); $f->addText('my_email', 'Testovací email'); $f->addSubmit('btn_send_emails', 'Odoslať všetkým')->onClick[] = array($this, 'actionSendEmails'); $f->addSubmit('btn_send_to_me', 'Odoslať testovací email')->onClick[] = array($this, 'actionSendTestingEmail'); if (!$last_newsletter) { $email_template = new NFileTemplate(); $email_template->registerFilter(new NLatteFilter()); $email_template->setFile(WWW_DIR . '/newsletter/templates/1/1.phtml'); $email_template->text = ''; $values['text'] = (string) $email_template; } else { $values = $last_newsletter; } $f->setDefaults($values); return $f; break; case 'addForm': $f = new MyForm(); $f->addText('emails', 'Email'); $f->addSubmit('btn', 'Pridať'); $f->onSuccess[] = array($this, 'handleAddEmail'); return $f; break; default: return parent::createComponent($name); break; } }
function createComponent($name) { switch ($name) { case 'PollTabella': $grid = new Tabella(PollModel::getFluent()->toDataSource(), array('sorting' => 'desc', 'order' => 'id_poll', 'id_table' => 'id_poll', 'onSubmit' => function ($values) { PollModel::edit($values, $values['id_poll']); }, 'onDelete' => function ($id_poll) { PollModel::delete($id_poll); })); $grid->addColumn("ID", "id_poll", array("width" => 30, 'editable' => true)); $grid->addColumn("Nadpis", "title", array("width" => 50, 'editable' => true)); $grid->addColumn("Otázka", "question", array('editable' => true)); $grid->addColumn("Popis", "description ", array("width" => 100)); $grid->addColumn("Od", "from_date", array("width" => 100)); $grid->addColumn("Do", "to_date", array("width" => 100)); $grid->addColumn("", "", array("width" => 30, 'filter' => NULL, "renderer" => function ($row) { $el = NHtml::el("td"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deletePoll!', array('id' => $row->id_poll)))->addClass('deleteIcon ajax')); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('edit', array('id' => $row->id_poll)))->addClass('editIcon')); $span = NHtml::el('span'); $el->add($span); return $el; })); $this->addComponent($grid, $name); break; case 'baseForm': $f = new MyForm(); $f->addText('title', 'Názov')->addRule(NForm::FILLED, 'Názov musí byť vyplnený'); $f->addText("question", "Otázka"); $f->addText("description", "Popis"); $f->addDateTimePicker("from_date", "Od")->addRule(NForm::FILLED, 'Zadajte datum a čas.'); $f->addDateTimePicker("to_date", "Do")->addRule(NForm::FILLED, 'Zadajte datum a čas.'); return $f; break; case 'addForm': $f = $this->createComponent('baseForm'); $f->addSubmit('btn', 'Pridať'); $f->onSuccess[] = array($this, 'handleAddPoll'); return $f; break; case 'editPollForm': $f = $this->createComponent('baseForm'); $f->addHidden('id_poll'); $f->addSubmit('btn', 'Upraviť'); $f->onSuccess[] = array($this, 'handleEditPoll'); $values = PollModel::get($this->getParam('id')); $f->setDefaults($values); return $f; break; case 'AnswerTabella': $grid = new Tabella(PollModel::getAnswerFluent($this->getParam('id'))->toDataSource(), array('sorting' => 'asc', 'order' => 'sequence', 'id_table' => 'id_poll_answer', 'onSubmit' => function ($values) { PollModel::editAnswer($values, $values['id_poll_answer']); }, 'onDelete' => function ($id_poll_answer) { PollModel::deleteAnswer($id_poll_answer); })); $el = NHtml::el("div"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyAnswer!', array('id_poll' => $this->getPresenter()->getParam('id'))))->addClass('addIcon ajax')); $grid->addColumn($el, 'sequence', array('width' => 10, 'filter' => NULL, "editable" => true)); //$grid->addColumn( "ID","id_poll_answer", array( "width" => 30,'editable'=>false,'filter'=>null ) ); $grid->addColumn("Odpoveď", "answer", array('filter' => null, "width" => 550, 'editable' => true)); // $grid->addColumn( "Správna?", "correct", array( // // "options" => array( '0' => 'Nie', '1' => 'Áno' ), // "width" => 50, // "editable" => true, // ) // ); $grid->addColumn("", "", array("width" => 30, 'filter' => NULL, "renderer" => function ($row) { $el = NHtml::el("td"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deletePollAnswer!', array('id' => NEnvironment::getApplication()->getPresenter()->getParam('id'), 'id_poll_answer' => $row->id_poll_answer)))->addClass('deleteIcon ajax')); $span = NHtml::el('span'); $el->add($span); return $el; })); $this->addComponent($grid, $name); break; default: return parent::createComponent($name); break; } }
function input($name, $display, $data = []) { $data['size'] = '10'; return MyForm::field($name, $display, $data); }
function createComponentForm($name) { $f = new MyForm(); $f->addHidden('id_product_template_group'); $f->addGroup('Nastavenie skupiny'); $f->addText('group_name', 'Názov skupiny')->addRule(NForm::FILLED, 'Názov skupiny musí byť vyplnený'); $f->addCheckbox('default', 'Predvolená skupina?'); $f->addCheckbox('allow_change_price', 'Možnosť meniť cenu pre jednotlivé parametre?'); $f->addGroup('Parametre'); $rows = $this->model->getProductParamRows(); foreach ($rows as $k => $r) { $f->addCheckbox($r, $r); } $f->addGroup(''); $f->addSubmit('btn', 'Uložiť'); $f->onSuccess[] = array($this, 'handleSave'); return $f; }
/** * Form to show list of topics with checkboxes * * @access protected * @return Nette\Application\UI\Form * @since 1.0.0 */ protected function createComponentForumTopicsForm() { $form = new MyForm(); $form->setMethod('get'); $container = $form->addContainer($this->forumSelectedTopicsContainer); foreach ($this->forumThreads as $thread) { $container->addCheckbox($thread->id_thread, $thread->title); } $form->addSubmit('show', 'View selected'); return $form; }
<?php /*~*/ use NitroXy\PHPForms\Form; function get_current_csrf_token() { return 'my-current-csrf-token'; } class MyForm extends Form { protected static function csrfToken() { return get_current_csrf_token(); } } MyForm::create("example_csrf", function ($f) { /* ... */ });
<?php /*~*/ use NitroXy\PHPForms\Form; class MyForm extends Form { protected static function defaultOptions() { return ['layout' => 'bootstrap']; } } MyForm::create("example_default_options", function ($f) { $f->textField('name', 'My field name'); });
public static function mark() { self::$old_model_name = self::$model_name; self::$old_is_array = self::$is_array; }
static function baseForm($check_email = true) { $form = new MyForm(); $renderer = $form->getRenderer(); $renderer->wrappers['group']['label'] = 'h3'; $form->addGroup(_('Informácie o zákazníkovi'))->setOption('container', 'fieldset id=user-info'); $form->addText('login', _('Používateľské meno / Email')); if ($check_email) { $form['login']->addRule(NForm::FILLED, _('Používateľské meno musí byť vyplnené'))->addRule(NForm::EMAIL, _('Používateľské meno musí byť email.')); } // $form->addText('email', _('Email')) // ->addRule(NForm::FILLED, _('Email musí byť vyplnený')) // ->addRule(NForm::EMAIL, _('Email nie je v správnom tvare')); $form->addPassword('password', _('Heslo')); $form->addPassword('passwordCheck', _('Znova heslo'))->addConditionOn($form['password'], NForm::FILLED)->addRule(NForm::FILLED, _('Zadejte heslo pro kontrolu'))->addRule(NForm::EQUAL, _('Hesla sa musia zhodovať'), $form['password']); /* * Info o uzivatelovi */ $form->addGroup('Účtovné informácie'); $form->addRadioList('type', '', array(0 => _('Súkromná osoba'), 1 => _('Podnikateľ - firma')))->addRule(NForm::FILLED, _('Uveďte či ste súkromná osoba alebo firma'))->setDefaultValue(0); //$form->addSelect('title', _('Oslovenie'), array( 0=>_('Žiadne'), 1=>_('Pán'),2=>_('Pani'),3=>_('Slečna') )); $form->addText('name', _('Meno'))->addRule(NForm::FILLED, _('Meno musí byť vyplnené')); $form->addText('surname', _('Priezvisko'))->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené')); $form->addText('address', _('Adresa'))->addRule(NForm::FILLED, _('Adresa musí byť vyplnená')); $form->addText('city', _('Mesto'))->addRule(NForm::FILLED, _('Mesto musí byť vyplnené')); $form->addText('zip', _('PSČ'))->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené')); $form->addSelect('iso', _('Štát'), UserModel::getAllCountry())->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené')); $form->addText('phone', _('Telefón'))->addRule(NForm::FILLED, _('Telefón musí byť vyplnený')); //$form->addText('fax', _('Fax')); $form->addGroup(_('Firemné informácie'))->setOption('container', 'fieldset id=company-form-container'); $form->addText('company_name', _('Názov spoločnosti '))->addConditionOn($form['type'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Názov spoločnosti musí byť vyplnený')); $form->addText('ico', _('IČO'))->addConditionOn($form['type'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('IČO spoločnosti musí byť vyplnené'))->addRule(NForm::MAX_LENGTH, 'Maximálna dĺžka je 12', 12); $form->addRadioList('paying_vat', _('Platca DPH'), array(0 => 'platca', 1 => 'neplatca'))->setDefaultValue(0)->addConditionOn($form['type'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('IČO spoločnosti musí byť vyplnené')); $form->addText('dic', _('DIČ'))->addConditionOn($form['type'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('DIČ spoločnosti musí byť vyplnené')); $form->addGroup(''); $form->addRadioList('use_delivery_address', _('Dodacia adresa'), array(0 => _('Prednastavená (rovnaká ako fakturačná adresa)'), 1 => _('Iná')))->setDefaultValue(0); $form->addGroup(_('Dodacia adresa'))->setOption('container', 'fieldset id=delivery-address-container'); //$form->addSelect('title', _('Oslovenie'), array( 0=>_('Žiadne'), 1=>_('Pán'),2=>_('Pani'),3=>_('Slečna') )); $form->addText('delivery_name', _('Meno'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Meno musí byť vyplnené')); $form->addText('delivery_surname', _('Priezvisko'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené')); $form->addText('delivery_address', _('Adresa'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Adresa musí byť vyplnená')); $form->addText('delivery_city', _('Mesto'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Mesto musí byť vyplnené')); $form->addText('delivery_zip', _('PSČ'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené')); $form->addSelect('delivery_iso', _('Štát'), UserModel::getAllCountry())->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené')); $form->addText('delivery_phone', _('Telefón')); return $form; }
protected function createComponent($name) { switch ($name) { case 'EshopProduct': $p = new EshopProductControl(); $p->invalidateControl(); return $p; break; case 'referenceForm': $params = NEnvironment::getApplication()->getPresenter()->getParam(); $form = new MyForm(); $form->addText('name', 'Meno:'); $form->addProtection(); $form->addText('email', 'Email:'); $form->addTextarea('text', 'Text:'); if (class_exists('reCAPTCHA')) { $form->addRecaptcha('recaptcha_input', 'Overenie:')->addRule('reCAPTCHA::validate', 'Prosím prepíšte správne text z obrázku.'); } $form->addSubmit('submit', 'Odoslať'); $form->onSuccess[] = array($this, 'handleSendReference'); $form->addHidden('id_product'); $form->setDefaults(array('id_product' => ProductModel::getIdProductByUrl($params['url_identifier'], 1))); return $form; break; default: return parent::createComponent($name); break; } }
@extends ('layout') @section ('content') <?php if ($categoria->exists) { $route = ['modulos_categorias.update', $categoria->id]; } else { $route = 'modulos_categorias.store'; } ?> {{Form::model($categoria, ['route' => $route, 'id' => 'form'])}} <?php MyForm::setModel('categoria', false); ?> {{MyForm::input('text', 'nombre')}} {{Form::submit('Crear Categoria')}} {{Form::close()}} @stop
protected function createComponent($name) { switch ($name) { case 'article': return new ArticleControl(); break; case 'questionToSeller': $f = new QuestionToSeller(); $f->setDefaults(array('link' => $_SERVER['HTTP_HOST'] . $this->link('this'))); return $f; break; case 'searchform': $f = new MyForm(); $f->addText('q', 'hľadané slovo / výraz')->getControlPrototype()->class = 'no-border'; //->addRule( NForm::FILLED, 'Hľadané slovo musí byť vyplnené'); $f->addSubmit('btn', 'Vyhľadať')->getControlPrototype()->class = 'no-border'; $f->onSuccess[] = array($this, 'searchFormSubmitted'); $f->setDefaults(array('q' => $this->getParam('q'))); return $f; break; case 'poll': $p = new PollControl(); return $p; break; /* * Pomocka pre pohyb admina po Front */ /* * Pomocka pre pohyb admina po Front */ case 'adminBar': return new AdminBarControl(); break; /* * Sluzi na zobrazenie vypredajovych poloziek * prislusenstva * noviniek */ /* * Sluzi na zobrazenie vypredajovych poloziek * prislusenstva * noviniek */ case 'productNewsSaleAvaiableTable': return new ProductNewsSaleAvaiableTableControl(); break; case 'Home': return new SlideshowControl(); break; case 'breadcrumb': return new BreadcrumbControl(); break; case 'quickFilter': return new QuickFilterControl(); break; case 'cart': $cart = new CartControl(); return $cart; break; case 'cartsmall': $cart = new CartSmallControl(); return $cart; break; case 'gmap': return new GmapControl(); break; case 'newsletter': return new NewsletterControl(); break; case 'UserForm': return new UserFormControl(); break; case 'LoginForm': return new LoginControl(); break; case 'userProfil': return new UserProfilControl(); break; case 'cartLogin': return new CartLoginControl(); break; // // case 'EshopProduct' : // $p = new EshopProductControl; // $p->invalidateControl(); // return $p; // break; // // case 'Redirect' : // return new RedirectControl (); // break; // // case 'EshopProduct' : // $p = new EshopProductControl; // $p->invalidateControl(); // return $p; // break; // // case 'Redirect' : // return new RedirectControl (); // break; case 'ContactForm': return new ContactFormControl(); break; // case 'comment' : // return new CommentControl (); // break; // case 'comment' : // return new CommentControl (); // break; case 'msg': return new MsgControl(); break; case 'vizionWidget': $widget = new VizionWidgetControl(); $widget->setWidgetService($this->getService('Widget')); return $widget; break; case 'userBaseForm': $form = UserModel::baseForm(); $_convertor_lang_to_iso = array('sk' => 'SVK', 'cz' => 'CZE', 'de' => 'DEU', 'en' => 'GB', 'hu' => 'HUN'); $form->setDefaults(array('type' => 0, 'iso' => $_convertor_lang_to_iso[$this->lang], 'delivery_iso' => $_convertor_lang_to_iso[$this->lang])); return $form; break; default: return parent::createComponent($name); break; } }
protected function createComponent($name) { switch ($name) { case 'JsTree': $tree = new JsTree(); $tree->keyColumn = 'id_category'; $tree->parentColumn = 'id_parent'; $tree->table = "category"; // jméno tabulky, s kterou bude pracovat $tree->titleColumn = "name"; // jméno sloupce pro titulek $tree->orderColumn = "sequence"; // jméno sloupce pro pořadí $tree->numberingFrom = 0; // $tree->parentColumn = "parent"; //$tree->where = array(array("`web`=%i", WEB)); // je možné navěsit podmínky //$tree->defaultValues = array("web"=>WEB); $tree->enableContextmenu = false; $tree->enableDragDrop = true; $tree->enableDragDropOrder = false; $tree->showRoot = false; $tree->enableCheckbox = false; // zobrazení checkboxů $tree->checkboxColumn = "checked"; // sloupec, který ovlivňuje stav checkboxu $tree->onAfterUpdate[] = callback($this, "updateUrl"); $tree->onAfterCreate[] = callback($this, "updateUrl"); $tree->onClick[] = callback($this, "handleClick"); $tree->openAll = true; return $tree; break; case 'changePrice': $f = new MyForm(); $f->addText('coeficient', NHtml::el('p')->add('Upraviť ceny v danej kategórii podľa koeficientu.')->add(NHtml::el('div')->add('Napr. ak chcete zvýšiť cenu o 10 percent, zadáte koeficient 1.10, ak o 25 percent 1.25. Ak chcete ceny znížiť o 10 percent, zadáte 0.90, ak o 15 percent, zadáte 0.85. Želanú kategóriu si zvolíte v ľavom v menu. Cena bude zaokrúhlená!')->addClass('silver')))->addRule(NForm::FILLED, 'Koeficient musí byť vyplnený'); $f->addSubmit('btn_percent', "Prepočitať"); $f->onSuccess[] = array($this, 'handleChangePrice'); return $f; break; case 'addCategoryForm': $c = new CategoryFormControl(); $c->mode = 'add'; return $c; break; case 'editCategoryForm': $c = new CategoryFormControl(); $c->mode = 'edit'; return $c; break; case 'MyTree': $c = new MyTreeControl(); $c->invalidateControl(); return $c; break; default: return parent::createComponent($name); break; } }
private function formulario() { $pre = ''; $elementos = array(); $fields = array(); foreach ($this->campos as $campo) { $c = $this->build_campo($campo); if ($c['index'] !== 0) { //Lleno los campos $elementos[$c['index']] = $c['elemento']; //Lleno las reglas de validación para el modelo $fields[$c['index']] = $c['reglas']; } else { array_push($elementos, $c['elemento']); } } //$elementos['ajax'] = array('type' => 'hidden', 'value' => 'custom'); $botones = array('send' => array('type' => 'submit', 'label' => $this->config->mensaje_boton)); $config = array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data', 'activeForm' => array('id' => 'custom-form', 'enableAjaxValidation' => true, 'enableClientValidation' => true, 'errorMessageCssClass' => 'alert alert-error'), 'showErrors' => true, 'elements' => $elementos, 'buttons' => $botones); //Defino el modelo con los campos (y sus respectivas reglas de validación) $model = new CustomForm($fields); //Creo el formulario con la configuración y el modelo $form = new MyForm($config, $model); $this->performAjaxValidation($model); if (isset($_POST['CustomForm'])) { //Verificar si vienen campos de usuario para actualizar (Pendiente) $model->attributes = $_POST['CustomForm']; if ($model->validate()) { foreach ($model->attributes as $attr => $value) { if (substr($attr, 0, 4) === 'file') { $model->{$attr} = CUploadedFile::getInstance($model, $attr); $dir = Yii::getPathOfAlias('webroot') . '/uploads/' . date('Y') . '/' . date('m') . '/'; if (!is_dir($dir)) { mkdir($dir, 0755, true); } if ($model->{$attr}->saveAs($dir . $model->{$attr}->name)) { $model->{$attr} = '/uploads/' . date('Y') . '/' . date('m') . '/' . $model->{$attr}->name; } else { $model->{$attr} = null; } } } //$u_id = Yii::app()->user->getState('usuario_id'); //$u = Usuario::model()->findByPk($u_id); $enviado_a = false; //Verificar si se debe enviar por correo if (!is_null($this->config->correo)) { Yii::app()->crugemailer->enviar_datos_form($this->config->correo, $u, $model); //Si se envía el correo se agrega a la BD $enviado_a = $this->config->correo; } //Aquí almaceno el envío y sus datos $ef = new EnvioFormulario(); if ($ef->guardar_envio($this->config->id, $model, $enviado_a)) { return $this->config->mensaje_envio; } else { $pre = '<p>Occurió un error guardando la información</p>'; //print_r($ef->getErrors());exit(); } } } $custom_css = cs()->registerCss('form_custom_css', $this->config->custom_css); $custom_js = cs()->registerScript('form_custom_js', $this->config->custom_js, CClientScript::POS_READY); //$model->validatorList->add($newValidator); //print_r($model->validatorList);exit(); return $pre . $form->render(); }
function input($name, $display, $data = array()) { //$data['class'] = $name; $data['onkeyup'] = 'precio()'; $data['size'] = '6'; return MyForm::field($name, $display, $data); $value = Form::getValueAttribute($name); $f_name = "modulo[{$name}]"; return '<div class="input-field">' . Form::label($f_name, $display) . Form::text($f_name, $value, $data) . '</div>'; }
<?php /*~*/ use NitroXy\PHPForms\Form; use NitroXy\PHPForms\FormBuilder; class MyBuilder extends FormBuilder { public function myField($label) { $this->manual(false, $label, 'custom'); } } class MyForm extends Form { public static $defaultBuilderClass = MyBuilder::class; } MyForm::create("id", function ($f) { $f->myField('Label'); });