Example #1
0
 public function __construct($parent, $name, $action = '')
 {
     parent::__construct($parent, $name);
     $this->getElementPrototype()->class = 'login-form';
     $this->addProtection('STFU!');
     if ($action == '') {
         $request = $this->getHttpRequest();
         $value = $request->getCookie('login');
         $this->addText('login', 'Uživatelské jméno:	')->addRule(Form::FILLED, 'Prosím zadajte přihlašovací jméno.');
         $this['login']->getControlPrototype()->class = "input";
         if ($value) {
             $this->setValues(array('login' => $value));
         }
     }
     $this->addPassword('password', 'Heslo:')->addRule(Form::FILLED, 'Prosím zadajte heslo.');
     $this['password']->getControlPrototype()->addAttributes(array('class' => "input"));
     $this->addCheckbox('remember', 'Zapamatovat')->setValue(true);
     if ($action == '') {
         $this->addSubmit('send', 'Přihlásit');
         $this->onSuccess[] = array($this, 'formSubmited');
     } else {
         $this->addSubmit('send', 'Změnit');
         $this->onSuccess[] = array($this, 'editFormSubmited');
     }
     $this['send']->getControlPrototype()->addAttributes(array('class' => "submit"));
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     $renderer = $this->getRenderer();
     $renderer->wrappers['controls']['container'] = '';
     $renderer->wrappers['pair']['container'] = 'div class="form-group"';
     $renderer->wrappers['label']['container'] = '';
     $renderer->wrappers['control']['container'] = 'div class="col-sm-11"';
     $renderer->wrappers['control']['.submit'] = "btn btn-default";
     $renderer->wrappers['control']['.text'] = "form-control";
     $renderer->wrappers['control']['.select'] = "form-control";
     $renderer->wrappers['control']['.password'] = "******";
     $renderer->wrappers['control']['.email'] = "form-control";
     $renderer->wrappers['error'] = array('container' => 'div class=errors', 'item' => NULL);
     $form = $this->getForm();
     $form->getElementPrototype()->class('form-horizontal');
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->setAttribute('class', empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = TRUE;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->setAttribute('class', 'form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->class($control->getControlPrototype()->type);
         }
     }
 }
Example #3
0
 public function __construct(\Nette\Security\User $user)
 {
     parent::__construct();
     $this->user = $user;
     $this->createFields();
     $this->addEventListeners();
 }
Example #4
0
 /**
  * @param \Nette\ComponentModel\IContainer $parent
  * @param string $name
  * @param \Nette\Localization\ITranslator $translator
  */
 public function __construct(IContainer $parent = NULL, $name = NULL, ITranslator $translator)
 {
     parent::__construct($parent, $name);
     $this->mode = FormMode::CREATE_MODE;
     $this->setTranslator($translator);
     $renderer = $this->getRenderer();
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['pair']['container'] = 'div class=form-group';
     $renderer->wrappers['control']['container'] = 'div class=col-sm-9';
     $renderer->wrappers['label']['container'] = 'div class="col-sm-3 control-label"';
     $renderer->wrappers['control']['description'] = 'span class=help-block';
     $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
     $renderer->wrappers['control']['erroritem'] = 'span class="label label-danger"';
     $renderer->wrappers['pair']['.error'] = 'has-error';
     $renderer->wrappers['control']['.submit'] = 'btn btn-lg btn-primary';
     $renderer->wrappers['control']['.button'] = 'btn btn-lg btn-default';
     //$renderer->wrappers['control']['.text'] = 'form-control';
     //	dd($renderer);
     //	dd($renderer->wrappers['controls']);
     //	dd($renderer->wrappers['control']);
     // make form and controls compatible with Twitter Bootstrap
     $this->getElementPrototype()->class('form-horizontal');
     foreach ($this->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = TRUE;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->getControlPrototype()->addClass('form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
         }
     }
 }
Example #5
0
 public function __construct(CategoryService $categoryService, Category $editedCategory = null)
 {
     parent::__construct();
     $this->categoryService = $categoryService;
     $this->editedCategory = $editedCategory;
     $this->createFields();
 }
Example #6
0
 /**
  * FormBootstrap constructor.
  *
  * @param null|ITranslator $translator
  * @param null|string      $type null, inline, vertical
  */
 public function __construct($translator, $type = null)
 {
     if ($translator) {
         $this->setTranslator($translator);
     }
     parent::__construct();
 }
Example #7
0
 public function __construct()
 {
     parent::__construct();
     $this->addText('login', 'Login:'******'password', 'Heslo:')->setRequired();
     $this->addSubmit('submit', 'Přihlásit se')->getControlPrototype()->class('btn btn-primary btn-block');
 }
Example #8
0
 public function __construct(CategoryService $categoryService, Product $editedProduct = null)
 {
     parent::__construct();
     $this->categoryService = $categoryService;
     $this->editedProduct = $editedProduct;
     $this->createFields();
 }
Example #9
0
 public function __construct()
 {
     parent::__construct();
     $this->addText('title', 'Názov')->addRule(self::MAX_LENGTH, '"%label" môže mať maximálnu dĺžku %value.', 255)->setRequired('Prosím, vyplňte povinné pole %label.');
     $this->addTextArea('content', 'Obsah');
     $this->addSubmit('save', 'Uložiť');
 }
Example #10
0
 public function __construct(\Nette\ComponentModel\IContainer $parent, $name)
 {
     parent::__construct($parent, $name);
     $field = new \Netxten\Forms\Controls\HiddenFieldWithLabel('Search:');
     $field->setHtmlId('search');
     $this->addComponent($field, 'search');
     $this->addSubmit('submit', 'Search');
 }
Example #11
0
 public function __construct(Nette\ComponentModel\IContainer $parent = NULL, $name = NULL)
 {
     parent::__construct();
     $this->monitor('Nette\\Application\\UI\\Presenter');
     if ($parent !== NULL) {
         $parent->addComponent($this, $name);
     }
 }
Example #12
0
 /**
  * @param string $permanentLoginExpiration
  */
 public function __construct(CurrentCartService $currentCartService, \Nette\Security\User $user, $permanentLoginExpiration)
 {
     parent::__construct();
     $this->currentCartService = $currentCartService;
     $this->user = $user;
     $this->createFields();
     $this->addEventListeners($permanentLoginExpiration);
 }
Example #13
0
 public function __construct(ShipmentService $shipmentService, ShipmentHelper $shipmentHelper, Shipment $shipment = null, User $user = null)
 {
     parent::__construct();
     $this->shipmentService = $shipmentService;
     $this->shipmentHelper = $shipmentHelper;
     $this->shipment = $shipment;
     $this->user = $user;
     $this->createFields();
 }
 public function __construct()
 {
     parent::__construct();
     $this->addHidden('articleId');
     $this->addText('nick', 'Přezdívka')->addRule(Form::MAX_LENGTH, 'Maximálně 30 znaků', 30)->setRequired('Přezdívka je povinná');
     $this->addTextArea('content', 'Obsah')->setRequired('Obsah je povinný');
     $this->addSubmit('send', 'Potvrdit');
     $this->onSuccess[] = [$this, 'success'];
     return $this;
 }
Example #15
0
 public function __construct()
 {
     parent::__construct();
     $renderer = $this->getRenderer();
     $renderer->wrappers['controls']['container'] = '';
     $renderer->wrappers['pair']['container'] = '';
     $renderer->wrappers['label']['container'] = '';
     $renderer->wrappers['control']['container'] = '';
     $renderer->wrappers['control']['.submit'] = 'btn';
 }
Example #16
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     $this->modelLoader = $this->getPresenter()->context->modelLoader;
     $this->getElementPrototype()->novalidate('novalidate')->class[] = 'form-with-smooth-buttons';
     $renderer = $this->getRenderer();
     //        $renderer->wrappers['controls']['container'] = 'dl';
     //        $renderer->wrappers['pair']['container'] = NULL;
     //        $renderer->wrappers['label']['container'] = 'dt';
     //        $renderer->wrappers['control']['container'] = 'dd';
 }
Example #17
0
 public function __construct(\Nette\ComponentModel\IContainer $parent, $name)
 {
     parent::__construct($parent, $name);
     $this->addText('url', 'URL:')->setRequired('Need URL');
     $this->addText('title', 'Title:');
     $this->addText('published', 'Date:');
     $field = new \Netxten\Forms\Controls\HiddenFieldWithLabel('Tags:');
     $field->setHtmlId('tags');
     $this->addComponent($field, 'tags');
     $this->addSubmit('submit', 'Add');
 }
Example #18
0
 public function __construct()
 {
     parent::__construct();
     $renderer = $this->getRenderer();
     if ($renderer instanceof DefaultFormRenderer) {
         $renderer->wrappers['form']['container'] = 'div class=form';
         $renderer->wrappers['controls']['container'] = NULL;
         $renderer->wrappers['pair']['container'] = 'div class=controls';
         $renderer->wrappers['control']['container'] = NULL;
         $renderer->wrappers['label']['container'] = NULL;
     }
 }
Example #19
0
 public function __construct(Groups $groups)
 {
     parent::__construct();
     $this->addText('s', 'dotaz')->setAttribute('autofocus', true);
     $this->addSelect('sortBy', 'Seřadit podle:', array(SearchRequest::SORT_TIME => 'času', SearchRequest::SORT_RELEVANCE => 'relevance'));
     $this->addText('from', 'Autor:');
     $this->addContainer('groups');
     foreach ($groups->getList() as $group) {
         $this['groups']->addCheckbox($group->id, $group->name);
     }
     $this->addSubmit('send', 'Vyhledat');
 }
Example #20
0
 public function __construct($parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
     $renderer = $this->getRenderer();
     $this->getElementPrototype()->class[] = "form-horizontal";
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['pair']['container'] = "div class=control-group";
     $renderer->wrappers['control']['container'] = "div class=controls";
     $renderer->wrappers['control']['.submit'] = "btn btn-primary";
     $renderer->wrappers['label']['requiredsuffix'] = "<span style='color: red'>*</span>";
     $renderer->wrappers['label']['container'] = NULL;
     $this->setRenderer($renderer);
 }
Example #21
0
 public function __construct($review, $reviewRepository, $rubrics, $translator)
 {
     parent::__construct();
     $this->review = $review;
     $this->solution = $review->solution;
     $this->reviewRepository = $reviewRepository;
     $solutionIsCompleteLabel = $translator->translate('messages.review.solutionIsComplete');
     $this->addCheckbox('solutionIsComplete', $solutionIsCompleteLabel);
     $rubricsContainer = $this->addContainer('rubrics');
     foreach ($rubrics as $id => $rubric) {
         if ($rubric instanceof \Model\Ontology\DefaultRubric) {
             $options = array();
             for ($score = 0; $score <= 3; $score++) {
                 $options[$score] = Html::el()->setHtml($this->renderRatingStars($score) . ' ' . $translator->translate('messages.review.score.' . $score), '<a><strong><em>');
             }
             $scoreLabel = $translator->translate('messages.review.score.title');
             $scorePlaceholder = $translator->translate('messages.review.useRubricsWhileChoosingScore');
             $rubricsContainer->addRadioList($id, $scoreLabel, $options);
         } elseif ($rubric instanceof \Model\Ontology\Rubric) {
             $options = array();
             foreach ($rubric->scale as $score => $description) {
                 $options[$score] = Html::el()->setHtml($this->renderRatingStars($score) . ' ' . strip_tags(Markdown::defaultTransform($description), '<a><strong><em>'));
             }
             $scoreLabel = $rubric->metric;
             $scorePlaceholder = $translator->translate('messages.review.useRubricsWhileChoosingScore');
             $rubricsContainer->addRadioList($id, $scoreLabel, $options);
         } elseif ($rubric instanceof \Model\Ontology\Checklist) {
             $checklistItems = array();
             foreach ($rubric->items as $order => $item) {
                 $desc = strip_tags(Markdown::defaultTransform($item->metric));
                 $weight = '<span class="label secondary weight" title="' . $translator->translate('messages.review.checklist.weight') . '"><i class="fa fa-pie-chart" aria-hidden="true"></i> <b>' . $item->weight . '</b></span>';
                 $checklistItems[] = Html::el()->setHtml($desc . ' ' . $weight)->setValue('1');
             }
             $rubricsContainer->addCheckboxList($id, $rubric->description, $checklistItems)->getControlPrototype();
         } elseif ($rubric instanceof \Model\Ontology\Comment) {
             $rubricsContainer->addTextarea($id, Html::el()->setHtml(Markdown::defaultTransform($rubric->instructions)))->setRequired($translator->translate('messages.review.verbalAsssessmentCompulsory'))->addRule(Form::MIN_LENGTH, $translator->translate('messages.review.assessmentMinimumLength', NULL, array('count' => 20)), 20);
         }
     }
     $notesLabel = $translator->translate('messages.review.notes');
     $this->addTextarea('notes', $notesLabel);
     $completeLabel = $translator->translate('messages.review.complete');
     $this->addCheckbox('complete', $completeLabel);
     $submitLabel = $translator->translate('messages.review.submit');
     $this->addSubmit('submit', $submitLabel);
 }
Example #22
0
 /**
  * @param Context $db
  * @param Selection $selection
  */
 public function __construct(Context $db, Selection $selection)
 {
     parent::__construct();
     $this->db = $db;
     $this->selection = $selection;
     $this->prepare();
     $this->addSubmit('submit', 'Uložit')->getControlPrototype()->class('btn btn-primary');
     // setup form rendering
     $renderer = $this->getRenderer();
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['pair']['container'] = 'div class=form-group';
     $renderer->wrappers['pair']['.error'] = 'has-error';
     $renderer->wrappers['control']['container'] = 'div class=col-sm-9';
     $renderer->wrappers['label']['container'] = 'div class="col-sm-3 control-label"';
     $renderer->wrappers['control']['description'] = 'span class=help-block';
     $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
     // make form and controls compatible with Twitter Bootstrap
     $this->getElementPrototype()->class('form-horizontal');
 }
Example #23
0
 public function __construct($name, $skoly, $studia, $showFKS)
 {
     $this->_name = $name;
     parent::__construct();
     $file = APP_DIR . $this->_definitionFile;
     if (!is_file($file) || !is_readable($file)) {
         throw new \Nette\FileNotFoundException("File {$file} is missing or is not readable.");
     }
     \NeonFormFactory::createForm(file_get_contents($file), $this);
     $this['typ_studia']->setItems($this->getStudia($studia));
     $this['typ_studia']->setPrompt('Zvoľte typ štúdia');
     $this['skola']->setItems($this->getSkoly($skoly));
     $this['skola']->setPrompt('Zvoľte školu');
     $this['skola']->getControlPrototype()->class[] = 'chosen';
     /** Validation */
     $this['osoba.adresa.psc']->addRule(Form::PATTERN, 'PSČ má byť päťciferné číslo', '^(\\s*[0-9]){5}\\s*$');
     $this['osoba.email']->setType('email')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Neplatný email');
     $this['osoba.telefon']->addRule(Form::PATTERN, 'Zadajte platné telefónne číslo', '^\\s*[+]?(\\s*[0-9/])*\\s*$');
     $this['telefon_rodic']->addRule(Form::PATTERN, 'Zadajte platné telefónne číslo', '^\\s*[+]?(\\s*[0-9/])*\\s*$');
     $this['rocnik']->setType('number')->addRule(FORM::INTEGER, 'Ročník musí byť číslo od 1 do 10')->addRule(FORM::RANGE, 'Ročník musí byť číslo od 1 do 10', array(1, 10));
     $prefix = $this->getPrefix();
     $this['koresp_kam']->addCondition(FORM::EQUAL, '2')->toggle("{$prefix}-koresp_adresa.ulica-dt")->toggle("{$prefix}-koresp_adresa.ulica-dd")->toggle("{$prefix}-koresp_adresa.mesto-dt")->toggle("{$prefix}-koresp_adresa.mesto-dd")->toggle("{$prefix}-koresp_adresa.psc-dt")->toggle("{$prefix}-koresp_adresa.psc-dd");
     $this['koresp_adresa.ulica']->addConditionOn($this['koresp_kam'], FORM::EQUAL, '2')->addRule(FORM::FILLED, 'Vyplň korešpondenčnú adresu');
     $this['koresp_adresa.mesto']->addConditionOn($this['koresp_kam'], FORM::EQUAL, '2')->addRule(FORM::FILLED, 'Vyplň korešpondenčnú adresu');
     $this['koresp_adresa.psc']->addConditionOn($this['koresp_kam'], FORM::EQUAL, '2')->addRule(FORM::FILLED, 'Vyplň PSČ');
     $this['koresp_adresa.psc']->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'PSČ má byť päťciferné číslo', '^(\\s*[0-9]){5}\\s*$');
     $this['sustredeni']->addRule(Form::RANGE, 'Musí byť nezáp**né celé číslo', array(0, null));
     $this['celostatiek']->addRule(Form::RANGE, 'Musí byť nezáp**né celé číslo', array(0, null));
     $this['vyhier']->addRule(Form::RANGE, 'Musí byť nezáp**né celé číslo', array(0, null));
     $this['sustredeni']->setValue('0');
     $this['celostatiek']->setValue('0');
     $this['vyhier']->setValue('0');
     if ($showFKS) {
         $type = 'number';
     } else {
         $type = 'hidden';
     }
     $this['sustredeni']->setType($type);
     $this['celostatiek']->setType($type);
     $this['vyhier']->setType($type);
 }
 public function __construct($presenter, $questions)
 {
     parent::__construct();
     $this->presenter = $presenter;
     $course = $presenter->courseRegistry->course;
     $translator = $presenter->translator;
     $questionsContainer = $this->addContainer('questions');
     $commentsContainer = $this->addContainer('comments');
     foreach ($questions as $id => $question) {
         $label = Html::el()->setHtml(Markdown::defaultTransform($question->text));
         switch ($question->input) {
             case 'file':
                 $maxKb = $course->uploadMaxFilesizeKb;
                 $input = $questionsContainer->addUpload($id, $label)->addRule(Form::MAX_FILE_SIZE, $translator->translate('messages.unit.assignmentAttachmentNote', NULL, array('filesize' => $maxKb)), $maxKb * 1024)->setOption('description', $translator->translate('messages.unit.assignmentAttachmentNote', NULL, array('filesize' => $maxKb)));
                 break;
             default:
                 $input = $questionsContainer->addTextarea($id, $label);
                 $highlight = in_array($question->input, array('turtle', 'p5js')) ? 'javascript' : $question->input;
                 if ($question->isHighlightingAvailable()) {
                     $input->getControlPrototype()->class('highlight-' . $highlight);
                 }
         }
         if (isset($question->entity->answer)) {
             $input->setValue($question->entity->answer->text);
         } elseif ($question->prefill) {
             $input->setValue($question->prefill);
         }
         $comments = $commentsContainer->addTextarea($id)->setAttribute('placeholder', $translator->translate('messages.solution.addComments'));
         if (isset($question->entity->answer->comments)) {
             $comments->setValue($question->entity->answer->comments);
         }
     }
     $submitLabel = $translator->translate('messages.unit.submitAssignment');
     $this->addSubmit('submit', $submitLabel);
     $this->onSuccess[] = array($this, 'formSucceeded');
 }
Example #25
0
 public function __construct()
 {
     parent::__construct();
 }
Example #26
0
 public function __construct(\Nette\ComponentModel\IContainer $parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
 }
Example #27
0
 public function __construct(\Nette\ComponentModel\IContainer $parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
     $translator = $parent->getPresenter()->getService('translator');
     $this->setTranslator($translator);
 }
Example #28
0
 public function __construct()
 {
     parent::__construct();
     $this->createFields();
 }
Example #29
0
 /**
  * @param \Nette\ComponentModel\IContainer $parent
  * @param string $name
  */
 public function __construct(\Nette\ComponentModel\IContainer $parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
     $this->setRenderer(new Bs3FormRenderer());
 }
Example #30
0
 /**
  * @param Nette\ComponentModel\IContainer $parent
  * @param null $name
  * @param string $uploadDir
  */
 public function __construct(Nette\ComponentModel\IContainer $parent = NULL, $name = NULL, $uploadDir = "")
 {
     $this->uploadDir = $uploadDir;
     parent::__construct($parent, $name);
 }