-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaseForm.latte
More file actions
94 lines (85 loc) · 2.33 KB
/
Copy pathBaseForm.latte
File metadata and controls
94 lines (85 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{if $templateFile}
{import $templateFile}
{/if}
{varType ADT\Forms\Form $form}
{define errors}
{$control['form']->getRenderer()->renderErrors()|noescape}
{/define}
{define renderEl}
{if $el instanceof ADT\Forms\Section}
{varType ADT\Forms\Section $el}
<div {if $el->getName()}id="{$el->getHtmlId()}"{/if}>
{if $el->getOption('redrawHandlers')}
{if $control->isControlInvalid($el->getHtmlId())}
<div n:snippet="$el->getHtmlId()">
{include renderSection, section => $el}
</div>
{else}
<div id="{$control->getSnippetId($el->getHtmlId())}">
{include renderSection, section => $el}
</div>
{/if}
{foreach $el->getOption('redrawHandlers') as $_el}
{include renderControl control => $_el}
{/foreach}
{else}
{include renderSection, section => $el}
{/if}
</div>
{else}
{varType Nette\ComponentModel\Component $el}
{var $blockName = 'component-' . $el->lookupPath(Nette\Forms\Form::class)}
{ifset #$blockName}
{include #$blockName, component => $el}
{else}
{if $el instanceof ADT\Forms\StaticContainer}
{varType ADT\Forms\StaticContainer $el}
{foreach $el->getElements() as $_el}
{include renderEl, el => $_el}
{/foreach}
{else}
{include renderControl, control => $el}
{/if}
{/ifset}
{/if}
{/define}
{define renderSection}
{varType ADT\Forms\Section $section}
{var $blockName = 'section-' . $section->getName()}
{ifset #$blockName}
{include #$blockName, section => $section}
{elseif $section->getOption('blockName')}
{var $blockName = $section->getOption('blockName')}
{include #$blockName, section => $section}
{else}
{foreach $section->getElements() as $_el}
{include renderEl, el => $_el}
{/foreach}
{/ifset}
{/define}
{define renderControl}
{if !$control->getOption('rendered')}
{if $control instanceof \Nette\Forms\Controls\SubmitButton && !$control->getCaption() || $control instanceof Nette\Forms\Controls\HiddenField}
{input $control hidden => true}
{else}
{formPair $control}
{/if}
{/if}
{/define}
{define renderForm}
<div n:snippet="$control->getName()">
{form form}
{include errors}
{foreach $form->getElements() as $_el}
{include renderEl el => $_el}
{/foreach}
{/form}
</div>
{/define}
{snippetArea formArea}
{ifset #form}
{include #form}
{else}
{include renderForm}
{/ifset}
{/snippetArea}