commit e19aef4eebfe82a3edbb863802bbfc34f4506535
Author: Filip Jani <jsem@filek.cz>
Date:   Wed May 22 17:46:14 2019 +0200

    Re #7503 přidání knihovny pro dynamický formulář
    + vytvoření ukázkového formuláře a načítání jeho defaultních hodnot
    + latte šablona pro prvky formuláře

diff --git a/app/AdminModule/component/Example/ExampleDynamic.latte b/app/AdminModule/component/Example/ExampleDynamic.latte
new file mode 100644
index 0000000..a6ac10f
--- /dev/null
+++ b/app/AdminModule/component/Example/ExampleDynamic.latte
@@ -0,0 +1,48 @@
+{form form}
+    <div class="row mb-2">
+        <div class="col-1">
+            {label element}
+        </div>
+        <div class="col-9">
+            {input element}
+        </div>
+    </div>
+
+    <div n:multiplier="books">
+        <div class="row mb-2">
+            <div class="col-1"><label n:name="line">Řádka</label></div>
+            <div class="col-3"><input n:name="line" n:class="form-control" required></div>
+            <div class="col-1 offset-1"><label n:name="book">Knížka</label></div>
+            <div class="col-3"><input n:name="book" n:class="form-control"></div>
+            <div class="col-2">{btnRemove 'class' => 'btn btn-danger'}</div>
+        </div>
+    </div>
+
+    {btnCreate books class => 'btn btn-success'}
+
+    <div class="row mt-5">
+        <div class="col-2">
+            {input submit}
+        </div>
+    </div>
+
+    <hr class="mt-5">
+    <h4>Výsledky</h4>
+
+    <code>
+        {snippet results}
+            {ifset $results}
+                {foreach $results as $element => $value}
+                    {if $value instanceof \Nette\Utils\ArrayHash}
+                        {foreach $value as $el => $val}
+                            <b>Element:</b> {$element}[{$el}], <b>value:</b> {var_dump($val)}
+                            <br>
+                        {/foreach}
+                    {else}
+                        <b>Element:</b> {$element}, <b>value:</b> {$value}<br>
+                    {/if}
+                {/foreach}
+            {/ifset}
+        {/snippet}
+    </code>
+{/form}
\ No newline at end of file
diff --git a/app/AdminModule/component/Example/ExampleDynamic.php b/app/AdminModule/component/Example/ExampleDynamic.php
new file mode 100644
index 0000000..e9f8e07
--- /dev/null
+++ b/app/AdminModule/component/Example/ExampleDynamic.php
@@ -0,0 +1,82 @@
+<?php
+
+
+namespace App\AdminModule\Components;
+
+
+use App\Utils\Form;
+use Nette\Application\UI\Control;
+use Nette\Forms\Container;
+
+/**
+ * Ukázkový dynamický formulář - SMAZAT PŘI PŘEDÁNÍ!
+ *
+ * @package App\AdminModule\Components
+ */
+class ExampleDynamic extends Control
+{
+    public function render()
+    {
+        $this->template->setFile(__DIR__ . '/ExampleDynamic.latte');
+        $this->template->render();
+    }
+
+    public function createComponentForm()
+    {
+        $form = new Form;
+
+        $min = 1; // Minimální počet kopií které se zobrazí ve formuláři (tj. 1 = minimálně jednou tam budou ty prvky)
+
+        $form->addText('element', 'Další prvky');
+
+        // Definice dynamických prvků
+        $multiplier = $form->addMultiplier('books', function (Container $container)
+        {
+            $container->addText('line', 'Řádka');
+            $container->addText('book', 'Knížka');
+        }, $min);
+
+        // Definice tlačítek pro přidání / odebrání řádku
+        $multiplier->addCreateButton('Add')->addClass('btn btn-primary');
+        $multiplier->addRemoveButton('Remove')->addClass('btn btn-danger');
+
+        $form->setDefaults($this->getContainerDefaults());
+
+        $form->addSubmit('submit', 'Odeslat');
+        $form->onSuccess[] = [$this, 'formSuccess'];
+
+        return $form;
+    }
+
+    public function formSuccess(Form $form)
+    {
+        \Tracy\Debugger::barDump($form->getValues());
+        $this->template->results = $form->getValues();
+        $this->redrawControl('results');
+    }
+
+    /**
+     * Vrací testovací pole s defaultníma hodnotama pro ukázku jak se plní formulář při editaci
+     */
+    public function getContainerDefaults()
+    {
+        return [
+            'element' => 'Nějaký další prvky',
+            'books' =>  // název kontaineru v addMultiplier
+                [
+                    ['line' => '1.', 'book' => 'kniha 1.'],
+                    ['line' => '2.', 'book' => 'kniha 2.'],
+                    ['line' => '3.', 'book' => 'kniha 3.']
+                ]
+        ];
+    }
+
+}
+
+interface IExampleDynamicFactory
+{
+    /**
+     * @return ExampleDynamic
+     */
+    public function create();
+}
\ No newline at end of file
diff --git a/app/AdminModule/presenters/ExamplePresenter.php b/app/AdminModule/presenters/ExamplePresenter.php
new file mode 100644
index 0000000..d1f16cb
--- /dev/null
+++ b/app/AdminModule/presenters/ExamplePresenter.php
@@ -0,0 +1,26 @@
+<?php
+
+
+namespace App\AdminModule\Presenters;
+
+
+use App\AdminModule\Components\IExampleDynamicFactory;
+
+class ExamplePresenter extends BaseAdminPresenter
+{
+    /**
+     * @var IExampleDynamicFactory
+     */
+    private $dynamicFactory;
+
+    public function __construct(IExampleDynamicFactory $dynamicFactory)
+    {
+
+        $this->dynamicFactory = $dynamicFactory;
+    }
+
+    public function createComponentForm()
+    {
+        return $this->dynamicFactory->create();
+    }
+}
\ No newline at end of file
diff --git a/app/AdminModule/templates/Example/default.latte b/app/AdminModule/templates/Example/default.latte
new file mode 100644
index 0000000..2b1542c
--- /dev/null
+++ b/app/AdminModule/templates/Example/default.latte
@@ -0,0 +1,2 @@
+{block content}
+{control form}
\ No newline at end of file
diff --git a/app/config/components.neon b/app/config/components.neon
index b777638..9a3b01b 100644
--- a/app/config/components.neon
+++ b/app/config/components.neon
@@ -22,3 +22,6 @@ services:
     - App\AdminModule\Components\IBookEditFormFactory
 
     - App\FrontModule\Components\ITransliterationSearchResultListFactory
+
+    # Example - smazat při předání!
+    - App\AdminModule\Components\IExampleDynamicFactory
\ No newline at end of file
diff --git a/app/config/config.neon b/app/config/config.neon
index a6e3b77..42a60b1 100644
--- a/app/config/config.neon
+++ b/app/config/config.neon
@@ -14,3 +14,6 @@ session:
 services:
 	router: App\RouterFactory::createRouter
 	authenticator: App\Model\Authenticator
+
+extensions:
+    replicator: WebChemistry\Forms\Controls\DI\MultiplierExtension
diff --git a/composer.json b/composer.json
index 949db80..022c352 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,8 @@
 		"nette/utils": "^2.4",
 		"latte/latte": "^2.4",
 		"tracy/tracy": "^2.4",
-		"ublaboo/datagrid": "^5.6"
+		"ublaboo/datagrid": "^5.6",
+		"contributte/forms-multiplier": "^3.0"
 	},
 	"require-dev": {
 		"nette/tester": "^2.0"
diff --git a/composer.lock b/composer.lock
index f9de71c..b8993b5 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,52 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "6018197517a97474da6c1a7c8e26f4fc",
+    "content-hash": "cb338bcaa5ecca136cb052ce84ef77ac",
     "packages": [
+        {
+            "name": "contributte/forms-multiplier",
+            "version": "v3.0.6",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/contributte/forms-multiplier.git",
+                "reference": "c76e4dfb298174bbe0fcdf3b22130271236f69f6"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/contributte/forms-multiplier/zipball/c76e4dfb298174bbe0fcdf3b22130271236f69f6",
+                "reference": "c76e4dfb298174bbe0fcdf3b22130271236f69f6",
+                "shasum": ""
+            },
+            "require": {
+                "nette/forms": "^2.4",
+                "php": ">= 5.6"
+            },
+            "require-dev": {
+                "codeception/codeception": "^2.4",
+                "latte/latte": "^2.3",
+                "nette/application": "^2.3",
+                "nette/di": "^2.3",
+                "phpunit/phpunit": "~5.0 || ~6.0 || ~7.1.0",
+                "webchemistry/testing-helpers": "~1.1.2"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "WebChemistry\\Forms\\Controls\\": [
+                        "src/"
+                    ]
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "description": "Multiplier for nette forms",
+            "keywords": [
+                "Forms",
+                "multiplier",
+                "nette",
+                "webchemistry"
+            ],
+            "time": "2019-03-05T08:14:12+00:00"
+        },
         {
             "name": "latte/latte",
             "version": "v2.4.8",
