public function createComponentForm($name) { $form = new Form($this, $name); $form->getElementPrototype()->class[] = "ajax"; // activate AJAX in http://addons.nette.org/vojtech-dobes/nette-ajax-js $form->addText("textField", "Text field")->addRule(Form::FILLED, "This is required text field."); $form->addMultipleFileUpload("upload", "Attachments"); //->addRule('MultipleFileUpload\MultipleFileUpload::validateFilled',"You have to upload at least one file!") //->addRule('MultipleFileUpload\MultipleFileUpload::validateFileSize',"Files are together too large.",100*1024); //$form->addMultipleFileUpload("upload2","Second file uploader"); $form->addSubmit("send", "Submit your form!"); $form->onSuccess[] = $this->handleFormSuccess; // Invalidace snippetů $form->onError[] = array($this, "handleRedrawForm"); $form->onSuccess[] = array($this, "handleRedrawForm"); }
/** * Form for uploading photos * Can only be created on the Generate action page and accessed * by somebody with generate privileges or higher * * @Privilege('generate') * @Action('generate') */ protected function createComponentUploadPhotosForm() { $form = new Form(); $form->addProtection('Vypršel časový limit, odešlete formulář znovu'); $form->getElementPrototype()->class[] = "ajax"; $form->addHidden('id'); $form->addMultipleFileUpload("upload", "Fotky:")->addRule("MultipleFileUpload::validateFilled", "Musíte odeslat alespoň jeden soubor!")->addRule("MultipleFileUpload::validateFileSize", "Soubory jsou dohromady moc veliké!", 100 * 1024 * 1024); //100MiB if ($this->user->isAllowed('Admin:Default:Chronicle', 'show')) { $form->addCheckbox('showchronicle', 'Zobrazit kroniku')->setDefaultValue(TRUE); } $form->addSubmit("send", "Odeslat"); $form->onSuccess[] = $this->uploadPhotosFormSucceded; // snippet invalidation $form->onError[] = $this->handleRedrawForm; $form->onSuccess[] = $this->handleRedrawForm; return $form; }