Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
101 lines (91 sloc) 3.76 KB
{block #form}
{form $form}
{include #form-errors}
{include #form-body}
{/form}
{/block}
{define #form-errors}
<ul n:if="$form->ownErrors" class="error">
<li n:foreach="$form->ownErrors as $error">{$error|safeTranslate}</li>
</ul>
{/define}
{define #form-body}
{foreach $form->getGroups() as $group}
{include #group, group => $group, groupsIterator => $iterator}
{/foreach}
{include #controls, group => $form}
{/define}
{define #group}
{if $group->getOption('visual') && $group->getControls()}
<fieldset n:attr="id => $group->getOption('id')">
{include #group-caption, group => $group}
{include #controls, group => $group}
{if $group->getOption('embedNext') && !$groupsIterator->isLast()}
{php $groupsIterator->next()}
{include #group, group => $groupsIterator->current(), groupsIterator => $groupsIterator}
{/if}
</fieldset>
{/if}
{/define}
{define #group-caption}
<legend n:if="$group->getOption('label') !== null">{$group->getOption('label')|safeTranslate}</legend>
<p n:if="$group->getOption('description') !== null">{$group->getOption('description')|safeTranslate}</p>
{/define}
{define #controls}
{if}
<table n:inner-foreach="$group->getControls() as $control">
{continueIf $control->getOption('rendered') || $control->getOption('type') === 'hidden'}
{var $controlName = $control->lookupPath(\Nette\Forms\Form::class)}
{var $controlType = $control->getOption('type', 'default')}
{ifset #pair-name-{$controlName}}
{include #"pair-name-{$controlName}", control => $control, controlsIterator => $iterator}
{elseifset #pair-type-{$controlType}}
{include #"pair-type-{$controlType}", control => $control, controlsIterator => $iterator}
{else}
{include #pair-type-default, control => $control, controlsIterator => $iterator}
{/ifset}
</table>
{/if $iterations}
{/define}
{define #pair-type-default}
<tr n:class="$control->getOption('class'), $control->required ? required" n:attr="id => $control->getOption('id')">
<th>
{include #label, control => $control}
</th>
<td>
{var $controlName = $control->lookupPath(\Nette\Forms\Form::class)}
{var $controlType = $control->getOption('type', 'default')}
{ifset #control-name-{$controlName}}
{include #"control-name-{$controlName}", control => $control}
{elseifset #control-type-{$controlType}}
{include #"control-type-{$controlType}", control => $control}
{else}
{include #control-type-default, control => $control}
{/ifset}
</td>
</tr>
{/define}
{define #pair-type-button}
<tr>
<th></th>
<td n:inner-block="#control-type-button">
{if !$control->getOption('rendered')}
{include #control-type-default, control => $control}
{/if}
{if !$controlsIterator->isLast() && $controlsIterator->getNextValue()->getOption('type') === 'button'}
{php $controlsIterator->next()}
{include #control-type-button, control => $controlsIterator->current(), controlsIterator => $controlsIterator}
{/if}
</td>
</tr>
{/define}
{define #label}
{label $control /}
{/define}
{define #control-type-default}
{input $control}
<small n:if="$control->getOption('description') !== null">{$control->getOption('description')|safeTranslate}</small>
<span n:if="$control->errors" class="error" n:inner-foreach="$control->errors as $error">
{$error|safeTranslate}
</span>
{/define}
You can’t perform that action at this time.