/** * Formular pre editaciu udajov * @param boolean $admin * @param array $druh * @return Nette\Application\UI\Form */ public function create($admin, $druh, $ur_reg) { $this->ur_reg = $ur_reg; $form = new Form(); $form->addProtection(); $form->addGroup(); $form->addHidden('id'); $form->addHidden('id_udaje_typ'); if ($admin) { $form->addText('nazov', 'Názov prvku:', 20, 20)->addRule(Form::MIN_LENGTH, 'Názov musí mať spoň %d znaky!', 2)->setAttribute('class', 'heading')->setRequired('Názov musí byť zadaný!'); $form->addText('comment', 'Komentár k hodnote :', 90, 255)->addRule(Form::MIN_LENGTH, 'Komentár musí mať spoň %d znaky!', 2)->setRequired('Komentár musí byť zadaný!'); } else { $form->addHidden('nazov'); $form->addHidden('comment'); } $form->addText('text', 'Hodnota prvku:', 90, 255)->setRequired('Hodnota prvku musí byť zadaná!'); if ($admin) { $form->addCheckbox('spravca', ' Povolená zmena pre správcu')->setDefaultValue(1); $form->addCheckbox("druh_null", " Hodnota druhu je NULL")->setDefaultValue(1)->addCondition(Form::EQUAL, TRUE)->toggle("druh", FALSE); $form->addGroup()->setOption('container', Html::el('fieldset')->id("druh")); $form->addSelect('id_druh', 'Druhová skupina pre nastavenia:', $druh)->setDefaultValue(1); $form->setCurrentGroup(NULL);
/** * @param Category[] $categories * @param string|null $code * @return Form */ public function create($categories, $code = null) { $validaton_message = "Vyplňte prosím %s. Pomůže mi to lépe zpracovat výsledky průzkumu. Díky ;)"; $form = new Form($this->parent, $this->name); $form->addGroup("Obecné"); $sex = array(Respondent::GENDER_MALE => 'muž', Respondent::GENDER_FEMALE => 'žena'); $form->addRadioList('gender', 'Pohlaví:', $sex)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "svoje pohlaví"); $age = array(Respondent::AGE_15 => 'méne něž 15', Respondent::AGE_15_20 => '15-20', Respondent::AGE_21_30 => '21-30', Respondent::AGE_31_45 => '31-45', Respondent::AGE_46_60 => '46-60', Respondent::AGE_60 => 'více než 60'); $form->addRadioList('age', 'Věk', $age)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "svůk věk"); $truefalseoptions = array(1 => "Ano", 0 => "Ne"); $form->addRadioList("english", "Navštěvuji anglické webové stránky", $truefalseoptions)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "zda navštěvujete i anglické webové stránky"); $form->addRadioList("it", "Pracuji v oboru IT nebo tento obor studuji", $truefalseoptions)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "zda pracujete v oboru IT nebo ho studujete"); if ($code !== null) { $form->addHidden("code", $code); } $form->addTextArea("sites", "Jaké stránky často navštěvuji"); $devices = array(Respondent::DEVICE_COMPUTER => "Počítač nebo notebook", Respondent::DEVICE_PHONE => "Smartphone", Respondent::DEVICE_TABLET => "Tablet"); $form->addCheckboxList('device', 'K přístupu na internet používám:', $devices)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "které zařízení používáte pro přístup k internetu"); $form->addRadioList("device_most", "A z toho nejčastěji", $devices)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "které zařízení nejčastěji používáte pro přístup k internetu"); $period = array(EntityCategory::PERIOD_NEVER => "vůbec", EntityCategory::PERIOD_DAILY => "denně", EntityCategory::PERIOD_FEW_TIMES_A_WEEK => "několikrát týdně", EntityCategory::PERIOD_FEW_TIMES_A_MONTH => "několikrát měsíčně", EntityCategory::PERIOD_FEW_TIMES_A_YEAR => "několikrát ročně"); $categories_container = $form->addContainer("category"); foreach ($categories as $holder_category) { $category_container = $categories_container->addContainer($holder_category->getCategory()->id_category); $category_container->setCurrentGroup($categories_container->getForm()->addGroup($holder_category->getCategory()->label)); $category_container->addRadioList("period", "Jak často?", $period)->setAttribute("class", "buttons-group"); if ($holder_category->getChildren()) { $items = array(); foreach ($holder_category->getChildren() as $child) { $items[$child->id_category] = $child->label; } $category_container->addCheckboxList("items", $holder_category->getCategory()->child_label, $items)->setAttribute("class", "buttons-group"); } } $form->setCurrentGroup(NULL); $form->addGroup("Zajímá mě to"); $form->addText("nickname", "Nick (chci být v highscore)"); $form->addText("email", "E-mail")->setType("email"); $form->addTextArea("message", "Vzkaz"); $form->addSubmit("validate", "Pokračovat")->setAttribute("class", "btn btn-primary"); $form->addSubmit("nonvalidate", "Přejít rovnou k otázkám")->setValidationScope(FALSE)->setAttribute("class", "btn btn-default"); return $form; }
/** * Edit hlavne menu form component factory. * @return Nette\Application\UI\Form */ public function create($slider_i, $wwwDir) { $this->slider_i = $slider_i; $this->wwwDir = $wwwDir; $form = new Form(); $form->addProtection(); $form->addHidden('id'); $form->addGroup(); $form->addUpload('subor', 'Obrázok slideru')->setOption('description', 'Odporúčaný rozmer obrázku je: ' . $this->slider_i['x'] . 'x' . $this->slider_i['y'] . ' alebo násobky tejto veľkosti. Inak môže dôjsť k deformácii alebo orezaniu obrázku pri ukladaní!')->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'Obrázok musí byť JPEG, PNG alebo GIF.')->addRule(Form::MAX_FILE_SIZE, 'Maximálna veľkosť súboru je 1 MB.', 1024 * 1024); $form->addText('nadpis', 'Nadpis:', 50, 50); $form->addText('popis', 'Popis:', 50, 150); $form->addText('poradie', 'Poradie:', 10, 10); if ($slider_i['odkaz']) { $form->addText('id_hlavne_menu', 'Id článku pre odkaz:', 5, 5)->setType('number')->addCondition(Form::FILLED)->addRule(Form::INTEGER, 'Id článku musí byť číslo!'); } $form->addCheckbox("zobrazenie_null", " Obrázok sa zobrazí vždy")->addCondition(Form::EQUAL, TRUE)->toggle("zobr", FALSE); $form->addGroup()->setOption('container', Html::el('fieldset')->id("zobr")); $form->addText('zobrazenie', 'Zobrazenie:', 20, 20)->setOption('description', 'Zapíšte tie id hlavného menu, pre ktoré sa daný obrázok zobrazí. Ak viac id oddelte medzerou.'); $form->setCurrentGroup(NULL); $form->addSubmit('uloz', 'Ulož')->setAttribute('class', 'btn btn-success')->onClick[] = array($this, 'editSliderFormSubmitted');
public function createComponentPaymentAndShippingForm() { //$countries = $this->context->createReference()->getReference('country')->where('hidden', 0)->order('id')->fetchPairs('id', 'name_full'); $totalPrice = $this->cart->getTotalPrice(\CartItem::ITEM_NORMAL); if ($totalPrice >= $this->noShippingLimit) { $paymentType = $this->context->createReference()->getReference('payment')->where('name_nm', array('BANK'))->order('name_full')->fetchPairs('name_nm', 'name_full'); $shippingTypeBank = $this->context->createReference()->getReference('shipping')->where('name_nm', array('PERSON', 'SAVE', 'DPD'))->order('name_full')->fetchPairs('name_nm', 'name_full'); $shippingTypeCash = $this->context->createReference()->getReference('shipping')->where('name_nm', array())->fetchPairs('name_nm', 'name_full'); $shippingTypeCod = $this->context->createReference()->getReference('shipping')->where('name_nm', array())->fetchPairs('name_nm', 'name_full'); } else { $paymentType = $this->context->createReference()->getReference('payment')->where('name_nm', array('CASH', 'BANK', 'COD'))->order('name_full')->fetchPairs('name_nm', 'name_full'); $shippingTypeCash = $this->context->createReference()->getReference('shipping')->where('name_nm', array('PERSON', 'SAVE'))->fetchPairs('name_nm', 'name_full'); $shippingTypeBank = $this->context->createReference()->getReference('shipping')->where('name_nm', array('PERSON', 'SAVE', 'DPD'))->order('name_full')->fetchPairs('name_nm', 'name_full'); $shippingTypeCod = $this->context->createReference()->getReference('shipping')->where('name_nm', array('DPD'))->fetchPairs('name_nm', 'name_full'); } $saveList = $this->context->createReference()->getReference('save')->where('active', 1)->fetchPairs('id', 'name_full'); $form = new Form(); $form->addGroup('Způsob platby'); $form->addRadioList('payment', 'Způsob platby', $paymentType)->addCondition(Form::EQUAL, 'CASH')->toggle('CASH')->addCondition(Form::EQUAL, 'BANK')->toggle('BANK')->addCondition(Form::EQUAL, 'COD')->toggle('COD'); $form->addGroup('Doprava')->setOption('container', Html::el('fieldset')->id("CASH")->style("display:none")); $form->addRadioList('shippingCash', 'Způsob dopravy', $shippingTypeCash); $form->addSelect('saveListCash', 'Pobočka uloženky', $saveList)->setPrompt('- Vyberte pobočku -'); $form->addGroup('Doprava')->setOption('container', Html::el('fieldset')->id("BANK")->style("display:none")); $form->addRadioList('shippingBank', 'Způsob dopravy', $shippingTypeBank); $form->addSelect('saveListBank', 'Pobočka uloženky', $saveList)->setPrompt('- Vyberte pobočku -'); $form->addGroup('Doprava')->setOption('container', Html::el('fieldset')->id("COD")->style("display:none")); $form->addRadioList('shippingCod', 'Způsob dopravy', $shippingTypeCod); $form->addGroup('Doručovací údaje'); $form->addText('name', 'Jméno:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat jméno.')->setAttribute('class', 'text'); $form->addText('surname', 'Příjmení:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat příjmení.')->setAttribute('class', 'text'); $form->addText('phone', 'Telefonní číslo:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat telefon.')->setAttribute('class', 'text')->addRule(Form::INTEGER, 'Telefon musí být složen jen z čísel.'); $form->addText('email', 'E-mail:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat e-mail.')->setAttribute('class', 'text')->addRule(Form::EMAIL, 'Pole email musí obsahovat platnou emailovou adresu.'); $form->addText('street', 'Ulice:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat ulici.')->setAttribute('class', 'text'); $form->addText('city', 'Město:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat město.')->setAttribute('class', 'text'); $form->addText('zipcode', 'PSČ*:', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat PSČ.')->setAttribute('class', 'text'); $form->addGroup('Poznámka'); $form->addTextArea('note', 'Poznámka k objednávce', 100, 7); if ($this->getUser()->isLoggedIn()) { $form->setDefaults(array('payment' => 'CASH', 'shippingCash' => 'PERSON', 'shippingBank' => 'DPD', 'shippingCod' => 'SAVE', 'name' => $this->customerInformation['name'], 'surname' => $this->customerInformation['surname'], 'phone' => $this->customerInformation['phone'], 'email' => $this->customerInformation['email'], 'street' => $this->customerAddress['street'], 'city' => $this->customerAddress['city'], 'zipcode' => $this->customerAddress['zipcode'], 'country_id' => 1)); } else { $form->setDefaults(array('payment' => 'CASH', 'shippingCash' => 'PERSON', 'shippingBank' => 'DPD', 'shippingCod' => 'SAVE')); } if ($totalPrice >= $this->noShippingLimit) { $form->setDefaults(array('payment' => 'BANK', 'shippingBank' => 'PERSON')); } $form->setCurrentGroup(null); $form->addSubmit('submit', 'Potvrdit')->setAttribute('class', 'button floatLeft')->setAttribute('title', 'Potvrdit'); $form->onSuccess[] = callback($this, 'paymentShippingFormSubmitted'); return $form; }