Kufrik/vendor/nette/forms/examples/latte/form.latte

38 lines
963 B
Plaintext

{* Generic form template *}
{define form, $name}
<form n:name=$name>
{* List for form-level error messages *}
<ul class=error n:ifcontent>
<li n:foreach="$form->ownErrors as $error">{$error}</li>
</ul>
<fieldset n:foreach="$form->getGroups() as $group" n:attr="id => $group->getOption(id)">
<label n:ifcontent>{$group->getOption(label)}</label>
{include controls $group->getControls()}
</fieldset>
{include controls $form->getControls()}
</form>
{/define}
{define local controls, array $controls}
{* Loop over form controls and render each one *}
<table>
<tr n:foreach="$controls as $control"
n:if="!$control->getOption(rendered) && $control->getOption(type) !== hidden"
n:class="$control->required ? required">
<th>{label $control /}</th>
<td>
{input $control}
<span class=info n:ifcontent>{$control->getOption(description)}</span>
<span class=error n:ifcontent>{$control->error}</span>
</td>
</tr>
</table>
{/define}