commit d690b531b3a891d45fe951145ac31c5079dd0196
Author: vastja <vastja@gmail.com>
Date:   Wed Apr 29 13:10:11 2020 +0200

    Re #7933
    + základní funkcionalita formulářů v aplikaci - viz. Symfony forms

diff --git a/website/composer.json b/website/composer.json
index 906578b..4696e3b 100644
--- a/website/composer.json
+++ b/website/composer.json
@@ -15,7 +15,8 @@
         "symfony/framework-bundle": "5.0.*",
         "symfony/twig-pack": "*",
         "symfony/yaml": "5.0.*",
-        "symfony/asset": "*"
+        "symfony/asset": "*",
+		"symfony/form" : "*"
     },
     "require-dev": {
         "friendsofphp/php-cs-fixer": "^2.16",
diff --git a/website/src/Controller/HeatmapController.php b/website/src/Controller/HeatmapController.php
index d3e1aa0..5b9f1cb 100644
--- a/website/src/Controller/HeatmapController.php
+++ b/website/src/Controller/HeatmapController.php
@@ -2,7 +2,10 @@
 
 namespace App\Controller;
 
+use App\Entity\DataSet;
+use App\Form\Type\DataSetType;
 use App\OpenData\IOpenDataManager;
+use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 
@@ -10,8 +13,25 @@ class HeatmapController extends AbstractController {
     /**
      * @Route("/heatmap", name="heatmap")
      */
-    public function index() {
-        return $this->render('heatmap.html.twig');
+    public function index(Request $request) {
+        $dataSet = new DataSet();
+
+        $form = $this->createForm(DataSetType::class, $dataSet);
+        $form->handleRequest($request);
+
+        // $form->isValid()
+        $dataSet = $form->getData();
+        if ($form->isSubmitted()) {
+            $dataSet = $form->getData();
+            // Todo do something
+        }
+
+        return $this->render(
+            'heatmap.html.twig',
+            [
+                'form' => $form->createView(),
+            ]
+        );
     }
 
     /**
diff --git a/website/src/Entity/DataSet.php b/website/src/Entity/DataSet.php
new file mode 100644
index 0000000..ddb7dc8
--- /dev/null
+++ b/website/src/Entity/DataSet.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Entity;
+
+class DataSet {
+    protected $time;
+    protected $date;
+    protected $type;
+
+    public function setTime($time) {
+        $this->time = $time;
+    }
+
+    public function getTime() {
+        return $this->time;
+    }
+
+    public function setDate($date) {
+        $this->date = $date;
+    }
+
+    public function getDate() {
+        return $this->date;
+    }
+
+    public function setType($type) {
+        $this->type = $type;
+    }
+
+    public function getType() {
+        return $this->type;
+    }
+}
diff --git a/website/src/Form/DataSetType.php b/website/src/Form/DataSetType.php
new file mode 100644
index 0000000..e40fc7c
--- /dev/null
+++ b/website/src/Form/DataSetType.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Form\Type;
+
+use App\Entity\DataSet;
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
+use Symfony\Component\Form\Extension\Core\Type\SubmitType;
+
+class DataSetType extends AbstractType {
+    public function buildForm(FormBuilderInterface $builder, array $options) {
+        $builder
+            ->add('date', TextType::class)
+            ->add('time', ChoiceType::class, [
+                'choices' => [
+                    '0:00-1:00' => 0,
+                    '1:00-2:00' => 1,
+                    '2:00-3:00' => 2,
+                    '3:00-4:00' => 3,
+                    '4:00-5:00' => 4,
+                    '5:00-6:00' => 5,
+                    '6:00-7:00' => 6,
+                    '7:00-8:00' => 7,
+                    '8:00-9:00' => 8,
+                    '9:00-10:00' => 9,
+                    '10:00-11:00' => 10,
+                    '11:00-12:00' => 11,
+                    '12:00-13:00' => 12,
+                    '13:00-14:00' => 13,
+                    '14:00-15:00' => 14,
+                    '15:00-16:00' => 15,
+                    '16:00-17:00' => 16,
+                    '17:00-18:00' => 17,
+                    '18:00-19:00' => 18,
+                    '19:00-20:00' => 19,
+                    '20:00-21:00' => 20,
+                    '21:00-22:00' => 21,
+                    '22:00-23:00' => 22,
+                    '23:00-0:00' => 23,
+                ],
+            ])
+            ->add('type', ChoiceType::class, [
+                'choices' => [
+                    'Wi-Fi a drátové připojení' => 0,
+                    'JIS snímače' => 1,
+                    'Koloběžky' => 2,
+                ],
+            ])
+            ->add('submit', SubmitType::class);
+    }
+
+    public function configureOptions(OptionsResolver $resolver) {
+        $resolver->setDefaults([
+            'data_class' => DataSet::class,
+        ]);
+    }
+}
diff --git a/website/templates/heatmap.html.twig b/website/templates/heatmap.html.twig
index e45368f..b62652f 100644
--- a/website/templates/heatmap.html.twig
+++ b/website/templates/heatmap.html.twig
@@ -21,65 +21,67 @@
       </button>
 
       <div class="collapse navbar-collapse" id="navigation">
-        <form method="get">
+        
+        {{ form_start(form) }}
+
           <ul class="navbar-nav">
             <li class="nav-item">
-              <label for="date">Vyberte datum</label>
-              <input type="date" name="date" id="date" class="form-control" required>
+              {{ form_label(form.date, 'Vyberte datum') }}
+              {{
+                form_widget(form.date,
+                {
+                  'type' : 'date',
+                  'attr' : {
+                    'class' : 'form-control'
+                  }
+                })
+              }}
             </li>
 
             <li class="nav-item">
-              <label for="hour">Vyberte čas</label>
-              <select name="hour" id="hour" class="custom-select">
-                <option value="0">0:00&ndash;1:00</option>
-                <option value="1">1:00&ndash;2:00</option>
-                <option value="2">2:00&ndash;3:00</option>
-                <option value="3">3:00&ndash;4:00</option>
-                <option value="4">4:00&ndash;5:00</option>
-                <option value="5">5:00&ndash;6:00</option>
-                <option value="6">6:00&ndash;7:00</option>
-                <option value="7">7:00&ndash;8:00</option>
-                <option value="8">8:00&ndash;9:00</option>
-                <option value="9">9:00&ndash;10:00</option>
-                <option value="10">10:00&ndash;11:00</option>
-                <option value="11">11:00&ndash;12:00</option>
-                <option value="12">12:00&ndash;13:00</option>
-                <option value="13">13:00&ndash;14:00</option>
-                <option value="14">14:00&ndash;15:00</option>
-                <option value="15">15:00&ndash;16:00</option>
-                <option value="16">16:00&ndash;17:00</option>
-                <option value="17">17:00&ndash;18:00</option>
-                <option value="18">18:00&ndash;19:00</option>
-                <option value="19">19:00&ndash;20:00</option>
-                <option value="20">20:00&ndash;21:00</option>
-                <option value="21">21:00&ndash;22:00</option>
-                <option value="22">22:00&ndash;23:00</option>
-                <option value="23">23:00&ndash;0:00</option>
-              </select>
+              {{ form_label(form.date, 'Vyberte čas') }}
+              {{
+                form_widget(form.time, {
+                  'attr' : {
+                    'class' : "custom-select"
+                  }
+                })
+              }}             
             </li>
 
             <li class="nav-item">
-              <label for="dataset">Vybrané datové sady</label>
-              <select name="dataset" id="dataset" class="custom-select">
-                <option value="internet">Wi-Fi a drátové připojení</option>
-                <option value="jis">JIS snímače</option>
-                <option value="scoobikes">koloběžky</option>
-              </select>
+              {{ form_label(form.date, 'Vybrané datové sady') }}
+              {{
+                form_widget(form.type, {
+                  'attr' : {
+                    'class' : "custom-select"
+                  }
+                })
+              }}  
             </li>
 
             <li class="nav-item">
-              <button class="btn btn-secondary" type="submit">
-                Potvrdit výběr
-              </button>
+              {{
+                form_widget(form.submit,
+                {
+                  'label' : 'Potvrdit výběr',
+                  'type' : 'submit',
+                  'attr' : {
+                    'class': 'btn btn-secondary'
+                  }
+                })
+              }}
             </li>
 
             <li class="nav-item button">
               <h2>
                 <a href="{{ path('home') }}" class="nav-link">O&nbsp;projektu</a>
               </h2>
-            </li>
-          </ul>
-        </form>
+            </li> 
+          </ul> 
+        
+        {{ form_end(form) }}
+
       </div>
 
       <a href="{{ path('home') }}" class="navbar-button">
