Created
March 20, 2024 22:48
-
-
Save jtojnar/0c059c4b1671a9c7348d641a2578445d to your computer and use it in GitHub Desktop.
Trying to reproduce https://github.com/contributte/forms-multiplier/issues/97
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: | |
scanDirs: false | |
mapping: | |
*: ContributteDemos\FormMultiplier\*Presenter | |
extensions: | |
- Contributte\FormMultiplier\DI\MultiplierExtension | |
services: | |
routing.router: Nette\Application\Routers\SimpleRouter('Examples:default') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Multiplier demo</title> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Contributte Form Multiplier</h1> | |
{form form} | |
<div n:multiplier="emails"> | |
<input n:name="email" /> | |
</div> | |
{multiplier:add emails class: myClass} | |
{multiplier:add emails:5} | |
{/form} | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types = 1); | |
namespace ContributteDemos\FormMultiplier; | |
use Nette\Application\UI\Form; | |
use Nette\Application\UI\Presenter; | |
use Nette\Forms\Container; | |
use Contributte\FormMultiplier\Multiplier; | |
class ExamplesPresenter extends Presenter | |
{ | |
private Form $form; | |
public function renderDefault() | |
{ | |
} | |
public function createComponentForm() | |
{ | |
$this->form = $form = new Form(); | |
$emails = $this->form->addMultiplier('emails', function(Container $container): void { | |
$container->addText('email', 'Email'); | |
}); | |
$emails->addCreateButton('Add'); | |
$emails->addRemoveButton('Remove'); | |
$form->onSuccess[] = function ($form, $values) { | |
dump($values); | |
}; | |
return $form; | |
} | |
public function formatTemplateFiles(): array | |
{ | |
return [__DIR__ . '/ExamplesPresenter.latte']; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types = 1); | |
namespace ContributteDemos\FormMultiplier; | |
use Nette\Application\Application; | |
use Nette\Configurator; | |
require_once __DIR__ . '/../vendor/autoload.php'; | |
$configurator = new Configurator; | |
// $configurator->setDebugMode(false); | |
$configurator->enableTracy(__DIR__ . '/log'); | |
$configurator->setTempDirectory(__DIR__ . '/temp'); | |
$configurator->createRobotLoader()->addDirectory(__DIR__)->register(); | |
$configurator->addConfig(__DIR__ . '/config.neon'); | |
$container = $configurator->createContainer(); | |
$app = $container->getByType(Application::class); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment