1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
<?php
/**
* Nette Forms and HTML5.
*/
if (@!include 'Nette/loader.php') {
die('Install packages using `composer install`');
}
use Nette\Forms\Form;
use Tracy\Debugger;
use Tracy\Dumper;
Debugger::enable();
$form = new Form;
$form->addGroup();
$form->addText('query', 'Search:')
->setType('search')
->setAttribute('autofocus');
$form->addText('count', 'Number of results:')
->setType('number')
->setDefaultValue(10)
->addRule($form::INTEGER, 'Must be numeric value')
->addRule($form::RANGE, 'Must be in range from %d to %d', [1, 100]);
$form->addText('precision', 'Precision:')
->setType('range')
->setDefaultValue(50)
->addRule($form::INTEGER, 'Precision must be numeric value')
->addRule($form::RANGE, 'Precision must be in range from %d to %d', [0, 100]);
$form->addEmail('email', 'Send to email:')
->setAttribute('autocomplete', 'off')
->setAttribute('placeholder', 'Optional, but Recommended');
$form->addSubmit('submit', 'Send');
if ($form->isSuccess()) {
echo '<h2>Form was submitted and successfully validated</h2>';
Dumper::dump($form->getValues());
exit;
}
?>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Nette Forms and HTML5</title>
<link rel="stylesheet" media="screen" href="assets/style.css" />
<script src="https://nette.github.io/resources/js/netteForms.js"></script>
<h1>Nette Forms and HTML5</h1>
<?php echo $form ?>
<footer><a href="https://doc.nette.org/en/forms">see documentation</a></footer>
|