Permalink
Browse files

combined form.latte & bootstrap-form.latte

  • Loading branch information...
dg committed May 31, 2017
1 parent cbf477e commit ca64e11874f44c0a581cb4f076a9f2f32739d979
@@ -3,7 +3,7 @@
* @param array $flashes flash messages
*}

{import 'components/bootstrap-form.latte'}
{import 'components/form.latte'}

<!DOCTYPE html>
<html>

This file was deleted.

Oops, something went wrong.
@@ -15,3 +15,36 @@
</table>
</form>
{/define}


{* for Bootstrap v3 *}
{define bootstrap-form $form}
<form n:name=$form class=form-horizontal>
<ul class=error n:if="$form->ownErrors">
<li n:foreach="$form->ownErrors as $error">{$error}</li>
</ul>

<div n:foreach="$form->controls as $name => $input"
n:if="!$input->getOption(rendered) && $input->getOption(type) !== hidden"
n:class="form-group, $input->required ? required, $input->error ? has-error">

<div class="col-sm-2 control-label">{label $input}</div>

<div class="col-sm-10">
{if $input->getOption(type) in [text, select, textarea]}
{input $input class => form-control}
{elseif $input->getOption(type) === button}
{input $input class => "btn btn-default"}
{elseif $input->getOption(type) === checkbox}
<div class="checkbox">{input $input}</div>
{elseif $input->getOption(type) === radio}
<div class="radio">{input $input}</div>
{else}
{input $input}
{/if}

<span class=help-block n:ifcontent>{$input->error ?: $input->getOption(description)}</span>
</div>
</div>
</form>
{/define}

0 comments on commit ca64e11

Please sign in to comment.