-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: updated bootstrap examples
- Loading branch information
Showing
8 changed files
with
125 additions
and
161 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{* Generic form template for Bootstrap v5 *} | ||
|
||
<form n:name=$form> | ||
{* List for form-level error messages *} | ||
<ul class="alert alert-danger" n:ifcontent> | ||
<li n:foreach="$form->ownErrors as $error">{$error}</li> | ||
</ul> | ||
|
||
{* Loop over form controls and render each one *} | ||
<div n:foreach="$form->controls as $name => $input" | ||
n:if="!$input->getOption(rendered) && $input->getOption(type) !== hidden" | ||
n:class="mb-3, row, $input->required ? required, $input->error ? is-invalid"> | ||
|
||
{* Label for the input *} | ||
<div class="col-sm-3 col-form-label">{label $input /}</div> | ||
|
||
<div class="col-sm-9"> | ||
{* Conditionally render inputs based on their type with appropriate Bootstrap classes *} | ||
{if $input->getOption(type) in [text, select, textarea, datetime, file]} | ||
{input $input class => form-control} | ||
|
||
{elseif $input->getOption(type) === button} | ||
{input $input class => "btn btn-primary"} | ||
{while $iterator->nextValue?->getOption(type) === button} | ||
{input $iterator->nextValue class => "btn btn-secondary"} | ||
{do $iterator->next()} | ||
{/while} | ||
|
||
{elseif $input->getOption(type) in [checkbox, radio]} | ||
{var $items = $input instanceof Nette\Forms\Controls\Checkbox ? [''] : $input->getItems()} | ||
<div class="form-check" n:foreach="$items as $k => $v"> | ||
{input $input:$k class => form-check-input}{label $input:$k class => form-check-label /} | ||
</div> | ||
|
||
{elseif $input->getOption(type) === color} | ||
{input $input class => "form-control form-control-color"} | ||
|
||
{else} | ||
{input $input} | ||
{/if} | ||
|
||
{* Display input-level errors or descriptions, if present *} | ||
<span class=invalid-feedback n:ifcontent>{$input->error}</span> | ||
<span class=form-text n:ifcontent>{$input->getOption(description)}</span> | ||
</div> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
{* Generic form template *} | ||
|
||
<form n:name=$form> | ||
{* List for form-level error messages *} | ||
<ul class=error n:ifcontent> | ||
<li n:foreach="$form->ownErrors as $error">{$error}</li> | ||
</ul> | ||
|
||
<table> | ||
{* Loop over form controls and render each one *} | ||
<tr n:foreach="$form->controls as $input" | ||
n:if="!$input->getOption(rendered) && $input->getOption(type) !== hidden" | ||
n:class="$input->required ? required"> | ||
|
||
<th>{label $input /}</th> | ||
<td>{input $input} <span class=error n:ifcontent>{$input->error}</span></td> | ||
|
||
<td> | ||
{input $input} | ||
|
||
<span class=info n:ifcontent>{$input->getOption(description)}</span> | ||
<span class=error n:ifcontent>{$input->error}</span> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> |
Oops, something went wrong.