/** * Form to add a topic * * @access protected * @return Nette\Application\UI\Form * @since 1.0.0 */ protected function createComponentForumForm() { $form = new MyForm(); $form->addGroup(!$this->forumTopicId ? 'Topic' : 'Reply to topic'); $form->addText('name', 'Name:', 50, 40)->addRule($form::FILLED, 'Name must be filled.'); if (!$this->forumTopicId) { $form->addText('title', 'Title:', 50, 100)->addRule($form::FILLED, 'Title must be filled.'); } $form->addTextArea('topic', 'Comment:', 87, 5)->addRule($form::FILLED, 'Comment must be filled.'); $form->addProtection('Security token did not match. Possible CSRF attack.'); $form->addSubmit('insert', 'Insert'); $form->onSuccess[] = callback($this, 'forumFormSubmitted'); 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; } }