Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7d3ab7a4

Přidáno uživatelem Filip Jani před více než 5 roky(ů)

Re #7507 úprava formuláře

Zobrazit rozdíly:

app/AdminModule/component/Book/BookEditForm.latte
1 1
<div class="row">
2
    <div class="col-4">
2
    <div class="col-12">
3 3
        {control form}
4 4
    </div>
5 5
</div>
app/AdminModule/component/Book/BookOptionForm.latte
1
{form form}
2
<div class="row">
3
    <div class="col-12">
4

  
5
        <div class="row mb-2">
6
            <div class="col-4">
7
                {label \App\Model\Repository\TransliterationRepository::COLUMN_BOOK_ID}
8
            </div>
9
            <div class="col-8">
10
                {input \App\Model\Repository\TransliterationRepository::COLUMN_BOOK_ID}
11
            </div>
12
        </div>
13

  
14
        <div class="row mb-2">
15
            <div class="col-4">
16
                {label \App\Model\Repository\BookRepository::COLUMN_BOOK_ABREV}
17
            </div>
18
            <div class="col-8">
19
                {input \App\Model\Repository\BookRepository::COLUMN_BOOK_ABREV}
20
            </div>
21
        </div>
22

  
23
        <div class="row mb-2">
24
            <div class="col-4">
25
                {label \App\Model\Repository\BookRepository::COLUMN_BOOK_AUTHOR}
26
            </div>
27
            <div class="col-8">
28
                {input \App\Model\Repository\BookRepository::COLUMN_BOOK_AUTHOR}
29
            </div>
30
        </div>
31

  
32
        <div class="row mb-2">
33
            <div class="col-4">
34
                {label \App\Model\Repository\BookRepository::COLUMN_BOOK_NAME}
35
            </div>
36
            <div class="col-8">
37
                {input \App\Model\Repository\BookRepository::COLUMN_BOOK_NAME}
38
            </div>
39
        </div>
40

  
41
        <div class="row mb-2">
42
            <div class="col-4">
43
                {label \App\Model\Repository\BookRepository::COLUMN_BOOK_DESCRIPTION}
44
            </div>
45
            <div class="col-8">
46
                {input \App\Model\Repository\BookRepository::COLUMN_BOOK_DESCRIPTION}
47
            </div>
48
        </div>
49

  
50
        <div class="row mb-2">
51
            <div class="col-4">
52
                {label \App\Model\Repository\BookRepository::COLUMN_PLACE_OF_PUB}
53
            </div>
54
            <div class="col-8">
55
                {input \App\Model\Repository\BookRepository::COLUMN_PLACE_OF_PUB}
56
            </div>
57
        </div>
58

  
59
        <div class="row mb-2">
60
            <div class="col-4">
61
                {label \App\Model\Repository\BookRepository::COLUMN_DATE_OF_PUB}
62
            </div>
63
            <div class="col-8">
64
                {input \App\Model\Repository\BookRepository::COLUMN_DATE_OF_PUB}
65
            </div>
66
        </div>
67

  
68
        <div class="row mb-2">
69
            <div class="col-4">
70
                {label \App\Model\Repository\BookRepository::COLUMN_PAGES}
71
            </div>
72
            <div class="col-8">
73
                {input \App\Model\Repository\BookRepository::COLUMN_PAGES}
74
            </div>
75
        </div>
76

  
77
        <div class="row mb-2">
78
            <div class="col-4">
79
                {label \App\Model\Repository\BookRepository::COLUMN_VOLUME}
80
            </div>
81
            <div class="col-8">
82
                {input \App\Model\Repository\BookRepository::COLUMN_VOLUME}
83
            </div>
84
        </div>
85

  
86
        <div class="row mb-2">
87
            <div class="col-4">
88
                {label \App\Model\Repository\BookRepository::COLUMN_VOLUME_NO}
89
            </div>
90
            <div class="col-8">
91
                {input \App\Model\Repository\BookRepository::COLUMN_VOLUME_NO}
92
            </div>
93
        </div>
94

  
95
    </div>
96
</div>
97
{/form}
app/AdminModule/component/Book/BookOptionForm.php
10 10

  
11 11
class BookOptionForm extends BookEditForm
12 12
{
13

  
14
    public function render()
15
    {
16
        parent::render();
17
        $this->template->setFile(__DIR__ . '/BookOptionForm.latte');
18
        $this->template->render();
19
    }
20

  
21 13
    public function createComponentForm()
22 14
    {
23

  
24 15
        $this->form->addRadioList('book', 'Book option', [0 => 'Existing book', 1 => 'New book'])
25
            ->addCondition($this->form::EQUAL, 0)
16
                ->addCondition(Form::EQUAL, 0)
26 17
            ->toggle(TransliterationRepository::COLUMN_BOOK_ID)
27
            ->elseCondition($this->form::EQUAL, 1)
28
            ->toggle(BookRepository::COLUMN_BOOK_ABREV)
29
            ->toggle(BookRepository::COLUMN_BOOK_AUTHOR)
30
            ->toggle(BookRepository::COLUMN_BOOK_NAME)
31
            ->toggle(BookRepository::COLUMN_BOOK_SUBTITLE)
32
            ->toggle(BookRepository::COLUMN_BOOK_DESCRIPTION)
33
            ->toggle(BookRepository::COLUMN_PLACE_OF_PUB)
34
            ->toggle(BookRepository::COLUMN_DATE_OF_PUB)
35
            ->toggle(BookRepository::COLUMN_PAGES)
36
            ->toggle(BookRepository::COLUMN_VOLUME)
37
            ->toggle(BookRepository::COLUMN_VOLUME_NO)
18
            ->elseCondition(Form::EQUAL, 1)
19
                ->toggle(BookRepository::COLUMN_BOOK_ABREV)
20
                ->toggle(BookRepository::COLUMN_BOOK_AUTHOR)
21
                ->toggle(BookRepository::COLUMN_BOOK_NAME)
22
                ->toggle(BookRepository::COLUMN_BOOK_SUBTITLE)
23
                ->toggle(BookRepository::COLUMN_BOOK_DESCRIPTION)
24
                ->toggle(BookRepository::COLUMN_PLACE_OF_PUB)
25
                ->toggle(BookRepository::COLUMN_DATE_OF_PUB)
26
                ->toggle(BookRepository::COLUMN_PAGES)
27
                ->toggle(BookRepository::COLUMN_VOLUME)
28
                ->toggle(BookRepository::COLUMN_VOLUME_NO)
38 29
            ->endCondition();
39 30

  
40 31
        $this->form->addSelect(TransliterationRepository::COLUMN_BOOK_ID, 'Book', $this->bookRepository->getBookAbbrevForSelect())
41 32
            ->setOption('id', TransliterationRepository::COLUMN_BOOK_ID);
42 33

  
43
        $this->form->addText(BookRepository::COLUMN_BOOK_ABREV, 'Abbreviation')
44
            ->addRule(Form::REQUIRED, 'Field %label is required', TRUE)
45
            ->setOption('id', BookRepository::COLUMN_BOOK_ABREV);
46

  
47
        $this->form->addText(BookRepository::COLUMN_BOOK_AUTHOR, 'Author')
48
            ->setOption('id', BookRepository::COLUMN_BOOK_AUTHOR);
49

  
50
        $this->form->addText(BookRepository::COLUMN_BOOK_NAME, 'Name')
51
            ->addRule(Form::REQUIRED, 'Field %label is required', TRUE)
52
            ->setOption('id', BookRepository::COLUMN_BOOK_NAME);
53

  
54
        $this->form->addText(BookRepository::COLUMN_BOOK_SUBTITLE, 'Alternate name')
55
            ->setOption('id', BookRepository::COLUMN_BOOK_SUBTITLE);
56

  
57
        $this->form->addTextArea(BookRepository::COLUMN_BOOK_DESCRIPTION, 'Description')
58
            ->setOption('id', BookRepository::COLUMN_BOOK_DESCRIPTION);
59

  
60
        $this->form->addText(BookRepository::COLUMN_PLACE_OF_PUB, 'Publication place')
61
            ->setOption('id', BookRepository::COLUMN_PLACE_OF_PUB);
62

  
63
        $this->form->addText(BookRepository::COLUMN_DATE_OF_PUB, 'Publication date')
64
            ->setOption('id', BookRepository::COLUMN_DATE_OF_PUB);
65

  
66
        $this->form->addText(BookRepository::COLUMN_PAGES, 'Pages')
67
            ->setOption('id', BookRepository::COLUMN_PAGES);
68

  
69
        $this->form->addText(BookRepository::COLUMN_VOLUME, 'Volume')
70
            ->setOption('id', BookRepository::COLUMN_VOLUME);
71

  
72
        $this->form->addText(BookRepository::COLUMN_VOLUME_NO, 'Volume No.')
73
            ;
34
        // Vytvoření všech prvků z rodiče
35
        parent::createComponentForm();
74 36

  
75
        $this->form->setDefaults($this->getDefaults());
76
        $this->form->setDefaults(['book' => '1']);
37
        // Nastavení jejich ID jinak se neschovávají pomocí toggle
38
        foreach ($this->form->getControls() as $control)
39
        {
40
            $this->form[$control->getName()]->setOption('id', $control->getName());
41
        }
77 42

  
78
        $this->form->addSubmit('submit', 'Save');
43
        $this->form->setDefaults(['book' => 0]);
79 44

  
80 45
        $this->form->onSuccess[] = [$this, 'formSuccess'];
81 46

  

Také k dispozici: Unified diff