Created
August 21, 2012 08:27
-
-
Save maxxscho/3413489 to your computer and use it in GitHub Desktop.
Twitter Bootstrap Form Helper
This file contains hidden or 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
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* Generates the HTML for a Twitter Bootstrap Input | |
* | |
* @var string | |
* @author Markus Schober | |
**/ | |
if ( !function_exists('tb_horizontal_input')) { | |
function tb_horizontal_input($input_data, $labeling) | |
{ | |
$input_tpl = tb_standard_input_tpl(); | |
$error = (form_error($input_data['name'])) ? ' error' : ''; | |
$input_id = $input_data['id']; | |
$input = form_input($input_data); | |
$form = sprintf($input_tpl, $error, $input_id, $labeling['label'], $input, $labeling['desc']); | |
return $form; | |
} | |
} | |
if ( !function_exists('tb_horizontal_dropdown')) { | |
function tb_horizontal_dropdown($name, $options, $selected, $additional_data, $labeling) | |
{ | |
$input_tpl = tb_standard_input_tpl(); | |
$error = (form_error($name)) ? ' error' : ''; | |
$input_id = $additional_data['id']; | |
$additional_data = 'id="' . $additional_data['id'] . '" class="' . $additional_data['class'] . '"'; | |
$input = form_dropdown($name, $options, $selected, $additional_data); | |
$form = sprintf($input_tpl, $error, $input_id, $labeling['label'], $input, $labeling['desc']); | |
return $form; | |
} | |
} | |
/** | |
* Helper function for the standard template for | |
* <input> Elements for Twitter Bootstrap 2.0 | |
* | |
* @var string | |
**/ | |
if ( !function_exists('tb_standard_input_tpl')) { | |
function tb_standard_input_tpl() | |
{ | |
$input_tpl = '<div class="control-group%1$s"> | |
<label class="control-label" for="%2$s">%3$s</label> | |
<div class="controls"> | |
%4$s | |
<span class="help-inline">%5$s</span> | |
</div> | |
</div>'; | |
return $input_tpl; | |
} | |
} | |
//End of file MY_form_helper.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment