setMethod() public method

Sets form's method.
public setMethod ( $method ) : self
return self
Example #1
0
 */
define("APP_DIR", dirname(__FILE__));
require_once "../load.php";
require_once "example_library.php";
if (isset($_GET["logConsole"])) {
    require "logConsole.php";
}
use FileDownloader\Downloader\AdvancedDownloader;
use FileDownloader\FDTools;
use FileDownloader\FileDownload;
use Nette\Diagnostics\Debugger;
use Nette\Forms\Form;
// Generate form
$f = new Form("upload-form");
$f->getElementPrototype()->id = "frm";
$f->setMethod("GET");
$f->addSelect("speed", "Speed", array(1 => "1byte/s", 50 => "50bytes/s", 512 => "512bytes/s", 1 * FDTools::KILOBYTE => "1kb/s", 5 * FDTools::KILOBYTE => "5kb/s", 20 * FDTools::KILOBYTE => "20kb/s", 32 * FDTools::KILOBYTE => "32kb/s", 50 * FDTools::KILOBYTE => "50kb/s", 64 * FDTools::KILOBYTE => "64kb/s", 100 * FDTools::KILOBYTE => "100kb/s", 128 * FDTools::KILOBYTE => "128kb/s", 200 * FDTools::KILOBYTE => "200kb/s", 256 * FDTools::KILOBYTE => "256kb/s", 300 * FDTools::KILOBYTE => "300kb/s", 512 * FDTools::KILOBYTE => "512kb/s", 1 * FDTools::MEGABYTE => "1mb/s", 2 * FDTools::MEGABYTE => "2mb/s", 5 * FDTools::MEGABYTE => "5mb/s", 10 * FDTools::MEGABYTE => "10mb/s", 0 => "Unlimited"));
$f->addText("filename", "Filename")->addRule(Form::FILLED, "You must fill name!");
$f->addSelect("size", "Size", array(1 => "1MB", 4 => "4MB", 8 => "8MB", 16 => "16MB", 32 => "32MB", 64 => "64MB", 128 => "128MB", 256 => "256MB", 512 => "512MB"));
$f->addSelect("log", "Log called events?", array(0 => "No", 1 => "Yes (may cause CPU load)"));
$f->addSubmit("download", "Download!");
$f->setDefaults(array("speed" => 50, "filename" => "Some horrible file name - ěščřžýáíé.bin", "size" => 8, "log" => 1));
if ($f->isSubmitted() and $f->isValid()) {
    Debugger::enable(Debugger::PRODUCTION);
    // Log errors to file!
    $val = $f->getValues();
    $location = dirname(__FILE__) . "/cache/test-" . $val["size"] . "MB.tmp";
    if (!file_exists($location)) {
        generateFile($location, $val["size"] * 1024);
    }
    /* Interface with getters and setters */
Example #2
0
<div class="page-header">
<h1><i class="fa fa-search"></i> Search</h1>
</div>

<h2>Station logs</h2>
<?php 
// temporary until we get a list of stations
use Nette\Forms\Form;
use Kdyby\BootstrapFormRenderer\BootstrapRenderer;
$form = new Form();
$form->setRenderer(new BootstrapRenderer());
$form->setAction('/list');
$form->setMethod('GET');
//$form->addProtection();
$form->addText('station', 'Station')->setAttribute('placeholder', 'E11')->setRequired();
$form->addSubmit('search', 'Search for this station');
$form->render();