Skip to content

Instantly share code, notes, and snippets.

@eduardomart
Created January 8, 2015 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardomart/d7a3a0dc3fdcae1ea422 to your computer and use it in GitHub Desktop.
Save eduardomart/d7a3a0dc3fdcae1ea422 to your computer and use it in GitHub Desktop.
FormBuilder Template using Bootstrap
{* BOOTSTRAP FORM *}
{literal}
<script type="text/javascript">
function fbht(htid)
{
var fbhtc=document.getElementById(htid);
if (fbhtc)
{
if (fbhtc.style.display == 'none')
{
fbhtc.style.display = 'inline';
}
else
{
fbhtc.style.display = 'none';
}
}
}
</script>
{/literal}
{$fb_form_header}
{if $fb_form_done == 1}
{* This first section is for displaying submission errors *}
{if isset($fb_submission_error) && $fb_submission_error}
<div class="alert alert-warning">{$fb_submission_error}</div>
{if isset($fb_show_submission_errors) && $fb_show_submission_errors}
<ul>
{foreach from=$fb_submission_error_list item=thisErr}
<li>{$thisErr}</li>
{/foreach}
</ul>
{/if}
</div>
{/if}
{else}
{* this section is for displaying the form *}
{* we start with validation errors *}
{if isset($fb_form_has_validation_errors) && $fb_form_has_validation_errors}
<div class="alert alert-warning">
<ul>
{foreach from=$fb_form_validation_errors item=thisErr}
<li>{$thisErr}</li>
{/foreach}
</ul>
</div>
{/if}
{if isset($captcha_error) && $captcha_error}
<div class="alert alert-warning">{$captcha_error}</div>
{/if}
{* and now the form itself *}
{*
• • • BS3 |replace • • •
*}
{$fb_form_start|replace:'<form':'<form role="form" class="form-horizontal"'}
<div>{$fb_hidden}</div>
{if $total_pages gt 1}<span>{$title_page_x_of_y}</span>{/if}
{foreach from=$fields item=entry}
{if $entry->display == 1}
{strip}
{if $entry->needseds_div == 1}
<div class="form-group{if $entry->required == 1} required{/if}{if $entry->valid == 0} has-error{/if}">
{/if}
{if $entry->hide_name == 0}
<label class="col-lg-2 control-label" {if $entry->multiple_parts != 1} for="{$entry->input_id}"{/if}>{$entry->name}
{if $entry->required_symbol != ''}
{$entry->required_symbol}
{/if}
</label>
{/if}
{if $entry->multiple_parts == 1}
{section name=numloop loop=$entry->input}
{if $entry->label_parts == 1}
<div class="col-lg-6">{$entry->input[numloop]->input}&nbsp;{$entry->input[numloop]->name}</div>
{else}
{$entry->input[numloop]->input}
{/if}
{if isset($entry->input[numloop]->op) && $entry->input[numloop]->op}
{$entry->input[numloop]->op}
{/if}
{/section}
{else}
{if $entry->smarty_eval == '1'}
{eval var=$entry->input}
{else}
{********************* THIS IS WHERE FIELDS ARE DISPLAYED! *******************}
<div class="col-lg-6">
{*if $entry->valid == 0}
<p><span class="label label-danger pull-right">{$entry->error}</span></p>
{/if*}
{$entry->input|replace:'cms_textarea':'form-control'|replace:'type="text"':'type="text" class="form-control"'|replace:'type="email"':'type="email" class="form-control"'}
</div>
{/if}
{/if}
{if $entry->helptext != ''}&nbsp;
<a href="javascript:fbht('{$entry->field_helptext_id}')"><img src="modules/FormBuilder/images/info-small.gif" alt="Help" /></a>
<span id="{$entry->field_helptext_id}" style="display:none" class="fbr_helptext">
{$entry->helptext}
</span>
{/if}
{if $entry->needs_div == 1}
</div>
{/if}
{/strip}
{/if}
{/foreach}
{if $has_captcha == 1}
<div class="captcha">{$graphic_captcha}{$title_captcha}<br />{$input_captcha}</div>
{/if}
<div class="form-group">
<div class="col-lg-offset-2 col-lg-6">
{$prev}{$submit|replace:'cms_submit fbsubmit':'btn btn-primary'}
</div>
</div>
{$fb_form_end}
{/if}
{$fb_form_footer}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment