Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Codeigniter + Bootstrap 2/3 Form Builder

License

NotificationsYou must be signed in to change notification settings

wallter/codeigniter_bootstrap_form_builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Do you want to write forms 60% faster?

Or type 60% less?

Are you using Codegniter and Bootstrap 3?

Then this is the plugin for you!

CodeIgniter library to build form's styled with Bootstrap 3.It's got 5 steps:

  • Load Libraries
  • Open Form
  • Echo out the output of your chosen function
  • Close your form
  • Enjoy Easy form building
  1. Load Libraries==============

Load the Codeigniter form helper, then load the form_builder library.

$this->load->helper('form');$this->load->library('form_builder');
  1. Open Your form==============
<?= $this->form_builder->open_form(array('action' => '')); ?>
  1. Echo out your form==============
<?/* Prepare variables */$defaults_object_or_array_from_db = NULL;$item = new stdClass;$item->id = 33;$item->description = '';$years = range(intval(date('Y')), intval(date('Y')) + 20);$months = array_map(function ($n) {return str_pad($n, 2, '0', STR_PAD_LEFT);}, range(1, 12));$exp_month_options = array_combine($months, $months);$cc_exp_month = '05';$exp_year_options = array_combine($years, $years);$cc_exp_year = intval(date('Y')) + 5;$input_span = 'pull-left ';/* Build form */echo $this->form_builder->build_form_horizontal(array(array(/* HIDDEN */'id' => 'id','type' => 'hidden','value' => $item->id),array(/* INPUT */'id' => 'color','placeholder' => 'Item Color','input_addons' => array('pre' => 'color: #','post' => ';'),'help' => 'this is a help block'),array(/* DROP DOWN */'id' => 'published','type' => 'dropdown','options' => array('1' => 'Published','2' => 'Disabled')),array(/* TEXTAREA */'id' => 'description','type' => 'textarea','class' => 'wysihtml5','placeholder' => 'Item Description (HTML or rich text)','value' => html_entity_decode($item->description)),array(/* COMBINE */'id' => 'expiration_date','type' => 'combine', /* use `combine` to put several input inside the same block */'elements' => array(array('id' => 'cc_exp_month','label' => 'Expiration Date','autocomplete' => 'cc-exp-month','type' => 'dropdown','options' => $exp_month_options,'class' => $input_span . 'required input-small','required' => '','data-items' => '4','pattern' => '\d{1,2}','style' => 'width: auto;','value' => (isset($cc_exp_month) ? $cc_exp_month : '')),array('id' => 'cc_exp_year','label' => 'Expiration Date','autocomplete' => 'cc-exp-year','type' => 'dropdown','options' => $exp_year_options,'class' => $input_span . 'required input-small','required' => '','data-items' => '4','pattern' => '\d{4}','style' => 'width: auto; margin-left: 5px;','value' => (isset($cc_exp_year) ? $cc_exp_year : '')))),array(/* DATE */'id' => 'date','type' => 'date'),array(/* CHECKBOX */'id' => 'checkbox_group','label' => 'Checkboxes','type' => 'checkbox','options' => array(array('id' => 'checkbox1','value' => 1// If no label is set, the value will be used),array('id' => 'checkbox2','value' => 2,'label' => 'Two'))),array(/* RADIO */'id' => 'radio_group','label' => 'Radio buttons','type' => 'radio','options' => array(array('id' => 'radio_button_yes','value' => 1,'label' => 'Yes'),array('id' => 'radio_button_no','value' => 0,'label' => 'No'))),array(/* SUBMIT */'id' => 'submit','type' => 'submit')), $defaults_object_or_array_from_db);echo $this->form_builder->close_form();?>
  1. Close The Form==============
<?= $this->form_builder->close_form(); ?>

Produces:

<form action="" autocomplete="on" enctype="multipart/form-data" method="post" accept-charset="utf-8"><input type="hidden" name="id" value="33" /><div><label for="color">Color</label><div><div><span>color: #</span><input type="text" name="color" value="" placeholder="Item Color"  /><span>;</span></div><span>this is a help block</span></div></div><div><label for="published">Published</label><div><select name="published"><option value="1">Published</option><option value="2">Disabled</option></select></div></div><div><label for="description">Description</label><div><textarea name="description" cols="40" rows="10" placeholder="Item Description (HTML or rich text)" ></textarea></div></div><div><label for="expiration_date">Expiration Date</label><div><select name="cc_exp_month" label="Expiration Date" autocomplete="cc-exp-month" required="" data-items="4" pattern="\d{1,2}"><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05" selected="selected">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option></select><select name="cc_exp_year" label="Expiration Date" autocomplete="cc-exp-year" required="" data-items="4" pattern="\d{4}"><option value="2016">2016</option><option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option><option value="2020">2020</option><option value="2021" selected="selected">2021</option><option value="2022">2022</option><option value="2023">2023</option><option value="2024">2024</option><option value="2025">2025</option><option value="2026">2026</option><option value="2027">2027</option><option value="2028">2028</option><option value="2029">2029</option><option value="2030">2030</option><option value="2031">2031</option><option value="2032">2032</option><option value="2033">2033</option><option value="2034">2034</option><option value="2035">2035</option><option value="2036">2036</option></select></div></div><div><label for="date">Date</label><div><input type="date" name="date" value=""  /></div></div><div><label for="checkbox_group">Checkboxes</label><div><label><input type="checkbox" name="checkbox_group" value="1" label="1"  />1</label><label><input type="checkbox" name="checkbox_group" value="2" label="Two"  />Two</label></div></div><div><label for="radio_group">Radio buttons</label><div><label><input type="radio" name="radio_group" value="1" label="Yes"  />Yes</label><label><input type="radio" name="radio_group" value="0" label="No"  />No</label></div></div><div><label for="submit"></label><div><input type="submit" name="submit" value="Submit"  name="submit" value="" /></div></div></form>

ScreenShot

Releases

No releases published

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp