GithubHelp home page GithubHelp logo

tzs007 / codeigniter_bootstrap_form_builder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wallter/codeigniter_bootstrap_form_builder

0.0 1.0 0.0 293 KB

bootstrap_form_builder

License: MIT License

codeigniter_bootstrap_form_builder's Introduction

Codeigniter Bootstrap 3 Form Builder

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 3 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 ==============
<?
echo $this->form_builder->build_form_horizontal(
        array(
    array(
        '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(
        'id' => 'experation_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(
        'id' => 'submit',
        'type' => 'submit'
    )
        ), $defaults_object_or_array_from_db);
?>

Produces:

<form action="" method="post" accept-charset="utf-8" class="form-horizontal col-md-12">
	<input id="id" type="hidden" name="id" value="33">
         <div class="form-group">
        <label class="col-md-2 control-label" for="name">Color</label>
        <div class="col-md-9">
            <div class="input-group">
                <span class="input-group-addon">color: #</span>
                <input type="text" name="color" value="" id="color" placeholder="Item Color" help="this is a help block" class="form-control">
                <span class="input-group-addon">;</span>
            </div>
            <span class="help-block">this is a help block</span>
        </div>
    </div>
     <div class="form-group">
         <label class="col-md-2 control-label" for="name">Published</label>
         <div class="col-md-9">
             <select name="published" id="published"class=" valid">
                 <option value="1">Published</option>
                 <option value="2">Disabled</option>
             </select>
         </div>
     </div>
     <div class="form-group">
         <label class="col-md-2 control-label" for="name">Description</label>
         <div class="col-md-9">
             <textarea name="description" cols="40" rows="10" id="description" class="form-control wysihtml5" placeholder="Item Description (HTML or rich text)" >HTML</textarea>
         </div>
     </div>
     <div class="form-group">
     	 <label class="col-md-2 control-label" for="name"></label>
     	 <input type="submit" name="submit" value="Submit" class="form-control btn btn-primary">
     </div>
 </form>   

ScreenShot

  1. Close The Form ==============
<?= $this->form_builder->close_form(); ?>

codeigniter_bootstrap_form_builder's People

Contributors

wallter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.