| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Nette Forms containers example. |
| 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 |
// group First person |
| 18 |
$form->addGroup('First person'); |
| 19 |
$first = $form->addContainer('first'); |
| 20 |
$first->addText('name', 'Your name:'); |
| 21 |
$first->addText('email', 'Email:'); |
| 22 |
$first->addText('street', 'Street:'); |
| 23 |
$first->addText('city', 'City:'); |
| 24 |
// group Second person |
| 25 |
$form->addGroup('Second person'); |
| 26 |
$second = $form->addContainer('second'); |
| 27 |
$second->addText('name', 'Your name:'); |
| 28 |
$second->addText('email', 'Email:'); |
| 29 |
$second->addText('street', 'Street:'); |
| 30 |
$second->addText('city', 'City:'); |
| 31 |
// group for button |
| 32 |
$form->addGroup(); |
| 33 |
$form->addSubmit('submit', 'Send'); |
| 34 |
if ($form->isSuccess()) { |
| 35 |
echo '<h2>Form was submitted and successfully validated</h2>'; |
| 36 |
Dumper::dump($form->getValues()); |
| 37 |
exit; |
| 38 |
} |
| 39 |
?> |
| 40 |
<!DOCTYPE html> |
| 41 |
<meta charset="utf-8"> |
| 42 |
<title>Nette Forms containers example</title> |
| 43 |
<link rel="stylesheet" media="screen" href="assets/style.css" /> |
| 44 |
|
| 45 |
<h1>Nette Forms containers example</h1> |
| 46 |
|
| 47 |
<?php |
| 48 |
$form->render(); |
| 49 |
?> |
| 50 |
|
| 51 |
<footer><a href="https://doc.nette.org/en/forms">see documentation</a></footer> |
| 52 |
<?php |
| 53 |
|