PluginProbe
Packeta / 2.1
Packeta v2.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / deps / nette / forms / examples / html5.php

html5.php in Packeta 2.1, at deps/nette/forms/examples/html5.php

43 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Nette Forms and HTML5.
5 */
6 declare (strict_types=1);
7 namespace Packetery;
8
9 if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
10 die('Install packages using `composer install`');
11 }
12 use Packetery\Nette\Forms\Form;
13 use Packetery\Tracy\Debugger;
14 use Packetery\Tracy\Dumper;
15 Debugger::enable();
16 $form = new Form();
17 $form->addGroup();
18 $form->addText('query', 'Search:')->setHtmlType('search')->setHtmlAttribute('autofocus');
19 $form->addText('count', 'Number of results:')->setHtmlType('number')->setDefaultValue(10)->addRule($form::INTEGER, 'Must be numeric value')->addRule($form::RANGE, 'Must be in range from %d to %d', [1, 100]);
20 $form->addText('precision', 'Precision:')->setHtmlType('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]);
21 $form->addEmail('email', 'Send to email:')->setHtmlAttribute('autocomplete', 'off')->setHtmlAttribute('placeholder', 'Optional, but Recommended');
22 $form->addSubmit('submit', 'Send');
23 if ($form->isSuccess()) {
24 echo '<h2>Form was submitted and successfully validated</h2>';
25 Dumper::dump($form->getValues());
26 exit;
27 }
28 ?>
29 <!DOCTYPE html>
30 <meta charset="utf-8">
31 <title>Nette Forms and HTML5</title>
32 <link rel="stylesheet" media="screen" href="assets/style.css" />
33 <script src="https://nette.github.io/resources/js/3/netteForms.js"></script>
34
35 <h1>Nette Forms and HTML5</h1>
36
37 <?php
38 $form->render();
39 ?>
40
41 <footer><a href="https://doc.nette.org/en/forms">see documentation</a></footer>
42 <?php
43