Ako prepisat blok v sablone cez includovanu sablonu
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- duskohu
- Člen | 778
Caute, Neviete mi poradit, mam formular, ktory manaulne renderujem a potrebujem prepisat nejaky blok toho formulara ale ten blok co chcem prepisat je v includovanej sablone. neviete mi poradit ako na to?
Priklad:
form.latte toto je klasika renderovanie formulara ktory ma bloky
<form n:name=$form>
<ul class="error" n:if="$form->ownErrors" n:block="#errors">
<li n:foreach="$form->ownErrors as $error">{$error}</li>
</ul>
{foreach $form->groups as $group}
<fieldset n:if="$group->controls" n:block="#$group->options[name].'-group'">
<legend n:ifset="$group->options[label]">{$group->options[label]}</legend>
<p n:ifset="$group->options[description]">{$group->options[description]}</p>
<table n:block="#controls">
{foreach $group->controls as $field}
<tr n:if="!$field->getOption(rendered)" n:class="$field->required ? required" n:block="$field->name.'-row'">
<th n:block="#label">
{if $field instanceof Nette\Forms\Controls\Button || $field instanceof Nette\Forms\Controls\Checkbox}
{else}
{!$field->label}
{/if}
</th>
<td n:block="#control">
{!$field->control}
{if $field instanceof Nette\Forms\Controls\Checkbox}{!$field->label}{/if}
<small n:if="isset($field->options['description'])">{$field->options['description']}</small>
</td>
</tr>
{/foreach}
</table>
</fieldset>
{/foreach}
{include #controls, group => $form}
</form>
PageForm.latte nacitam form.latte
{includeblock 'form.latte', form => form}
{includeblock $template}// $template='nejaka-cesta-kde-je-blok.latte'; // toto sa mi nespusti
nejaka-cesta-kde-je-blok.latte – tu je ten blok ktory nacitavam a chcem prepisat blok v sablone formulara, neprepise mi blok formulara
{define #custom3-row}
<tr n:if="!$field->getOption(rendered)">
<th colspan=2>radek prvku 'username' vykreslime jinak:<br> {$field->label} {$field->control}</th>
</tr>
{/define}