commit 7d3ab7a4fba3dc1b88a2f18b18859ef2732cc93b
Author: Filip Jani <jsem@filek.cz>
Date:   Mon Jun 3 17:27:39 2019 +0200

    Re #7507 úprava formuláře

diff --git a/app/AdminModule/component/Book/BookEditForm.latte b/app/AdminModule/component/Book/BookEditForm.latte
index b6a732f..a7911a9 100644
--- a/app/AdminModule/component/Book/BookEditForm.latte
+++ b/app/AdminModule/component/Book/BookEditForm.latte
@@ -1,5 +1,5 @@
 <div class="row">
-    <div class="col-4">
+    <div class="col-12">
         {control form}
     </div>
 </div>
\ No newline at end of file
diff --git a/app/AdminModule/component/Book/BookOptionForm.latte b/app/AdminModule/component/Book/BookOptionForm.latte
deleted file mode 100644
index 200681d..0000000
--- a/app/AdminModule/component/Book/BookOptionForm.latte
+++ /dev/null
@@ -1,97 +0,0 @@
-{form form}
-<div class="row">
-    <div class="col-12">
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\TransliterationRepository::COLUMN_BOOK_ID}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\TransliterationRepository::COLUMN_BOOK_ID}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_BOOK_ABREV}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_BOOK_ABREV}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_BOOK_AUTHOR}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_BOOK_AUTHOR}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_BOOK_NAME}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_BOOK_NAME}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_BOOK_DESCRIPTION}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_BOOK_DESCRIPTION}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_PLACE_OF_PUB}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_PLACE_OF_PUB}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_DATE_OF_PUB}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_DATE_OF_PUB}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_PAGES}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_PAGES}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_VOLUME}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_VOLUME}
-            </div>
-        </div>
-
-        <div class="row mb-2">
-            <div class="col-4">
-                {label \App\Model\Repository\BookRepository::COLUMN_VOLUME_NO}
-            </div>
-            <div class="col-8">
-                {input \App\Model\Repository\BookRepository::COLUMN_VOLUME_NO}
-            </div>
-        </div>
-
-    </div>
-</div>
-{/form}
\ No newline at end of file
diff --git a/app/AdminModule/component/Book/BookOptionForm.php b/app/AdminModule/component/Book/BookOptionForm.php
index a01e6cd..ef857e0 100644
--- a/app/AdminModule/component/Book/BookOptionForm.php
+++ b/app/AdminModule/component/Book/BookOptionForm.php
@@ -10,72 +10,37 @@ use App\Utils\Form;
 
 class BookOptionForm extends BookEditForm
 {
-
-    public function render()
-    {
-        parent::render();
-        $this->template->setFile(__DIR__ . '/BookOptionForm.latte');
-        $this->template->render();
-    }
-
     public function createComponentForm()
     {
-
         $this->form->addRadioList('book', 'Book option', [0 => 'Existing book', 1 => 'New book'])
-            ->addCondition($this->form::EQUAL, 0)
+                ->addCondition(Form::EQUAL, 0)
             ->toggle(TransliterationRepository::COLUMN_BOOK_ID)
-            ->elseCondition($this->form::EQUAL, 1)
-            ->toggle(BookRepository::COLUMN_BOOK_ABREV)
-            ->toggle(BookRepository::COLUMN_BOOK_AUTHOR)
-            ->toggle(BookRepository::COLUMN_BOOK_NAME)
-            ->toggle(BookRepository::COLUMN_BOOK_SUBTITLE)
-            ->toggle(BookRepository::COLUMN_BOOK_DESCRIPTION)
-            ->toggle(BookRepository::COLUMN_PLACE_OF_PUB)
-            ->toggle(BookRepository::COLUMN_DATE_OF_PUB)
-            ->toggle(BookRepository::COLUMN_PAGES)
-            ->toggle(BookRepository::COLUMN_VOLUME)
-            ->toggle(BookRepository::COLUMN_VOLUME_NO)
+            ->elseCondition(Form::EQUAL, 1)
+                ->toggle(BookRepository::COLUMN_BOOK_ABREV)
+                ->toggle(BookRepository::COLUMN_BOOK_AUTHOR)
+                ->toggle(BookRepository::COLUMN_BOOK_NAME)
+                ->toggle(BookRepository::COLUMN_BOOK_SUBTITLE)
+                ->toggle(BookRepository::COLUMN_BOOK_DESCRIPTION)
+                ->toggle(BookRepository::COLUMN_PLACE_OF_PUB)
+                ->toggle(BookRepository::COLUMN_DATE_OF_PUB)
+                ->toggle(BookRepository::COLUMN_PAGES)
+                ->toggle(BookRepository::COLUMN_VOLUME)
+                ->toggle(BookRepository::COLUMN_VOLUME_NO)
             ->endCondition();
 
         $this->form->addSelect(TransliterationRepository::COLUMN_BOOK_ID, 'Book', $this->bookRepository->getBookAbbrevForSelect())
             ->setOption('id', TransliterationRepository::COLUMN_BOOK_ID);
 
-        $this->form->addText(BookRepository::COLUMN_BOOK_ABREV, 'Abbreviation')
-            ->addRule(Form::REQUIRED, 'Field %label is required', TRUE)
-            ->setOption('id', BookRepository::COLUMN_BOOK_ABREV);
-
-        $this->form->addText(BookRepository::COLUMN_BOOK_AUTHOR, 'Author')
-            ->setOption('id', BookRepository::COLUMN_BOOK_AUTHOR);
-
-        $this->form->addText(BookRepository::COLUMN_BOOK_NAME, 'Name')
-            ->addRule(Form::REQUIRED, 'Field %label is required', TRUE)
-            ->setOption('id', BookRepository::COLUMN_BOOK_NAME);
-
-        $this->form->addText(BookRepository::COLUMN_BOOK_SUBTITLE, 'Alternate name')
-            ->setOption('id', BookRepository::COLUMN_BOOK_SUBTITLE);
-
-        $this->form->addTextArea(BookRepository::COLUMN_BOOK_DESCRIPTION, 'Description')
-            ->setOption('id', BookRepository::COLUMN_BOOK_DESCRIPTION);
-
-        $this->form->addText(BookRepository::COLUMN_PLACE_OF_PUB, 'Publication place')
-            ->setOption('id', BookRepository::COLUMN_PLACE_OF_PUB);
-
-        $this->form->addText(BookRepository::COLUMN_DATE_OF_PUB, 'Publication date')
-            ->setOption('id', BookRepository::COLUMN_DATE_OF_PUB);
-
-        $this->form->addText(BookRepository::COLUMN_PAGES, 'Pages')
-            ->setOption('id', BookRepository::COLUMN_PAGES);
-
-        $this->form->addText(BookRepository::COLUMN_VOLUME, 'Volume')
-            ->setOption('id', BookRepository::COLUMN_VOLUME);
-
-        $this->form->addText(BookRepository::COLUMN_VOLUME_NO, 'Volume No.')
-            ;
+        // Vytvoření všech prvků z rodiče
+        parent::createComponentForm();
 
-        $this->form->setDefaults($this->getDefaults());
-        $this->form->setDefaults(['book' => '1']);
+        // Nastavení jejich ID jinak se neschovávají pomocí toggle
+        foreach ($this->form->getControls() as $control)
+        {
+            $this->form[$control->getName()]->setOption('id', $control->getName());
+        }
 
-        $this->form->addSubmit('submit', 'Save');
+        $this->form->setDefaults(['book' => 0]);
 
         $this->form->onSuccess[] = [$this, 'formSuccess'];
 
