Sie sind auf Seite 1von 10

GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.

com/zwacky/codeigniter_form_builder

Features Business Explore Pricing Sign in or Sign up

zwacky / codeigniter_form_builder 13 57 37

Code Issues Pull requests Projects Pulse Graphs

CodeIgniter library to build uniform form elements with bootstrap styling

13 commits 1 branch 0 releases 1 contributor

zwacky added type of button in multi fragment Latest commit d3d6198 on Jul 10, 2013

application/library added type of button in multi fragment 4 years ago

readme-data add missing assets 5 years ago

.gitignore Initial commit 5 years ago

README.md fixed typo and formatting 4 years ago

README.md

CodeIgniter Form Builder


CodeIgniter library to build uniform form elements with bootstrap styling. It makes building form elements faster and easier.
It's structured in 4 sections:

Initialization

1 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

Elements
Utility
Multi Elements

Initialization
put form_builder.php into your directory and you're ready to go. calling functions will output the html
right away. best to be used inside templates.

load inside controller:

$this->load->library('form_builder');

use inside template:

$this->form_builder->text('id_something', 'ID');

the functions hold default parameters that repeat themselves. they are the following:

default: the default value


class: additional css class(es)
placeholder: the html5 placeholder tag

Elements

Text

2 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

text($id, $name, $default = '', $class = 'input-large', $placeholder = '', $prepend = '', $append = '')

additional parameters:

prepend: prepended input (before text)


append: appended input (after text)

$this->form_builder->text('per_month', 'per Monat', '1350', 'input-large', 'Betrag', '', 'CHF');


$this->form_builder->text('per_month', 'per Woche', '', 'input-large', 'Betrag', '', 'CHF');

Password

password($id, $name, $default = '', $class = 'input-large', $placeholder = '', $prepend = '', $append = '')

additional parameters:

prepend: prepended input (before text)


append: appended input (after text)

$this->form_builder->password('password', 'Passwort', '12345');

3 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

Radio

radio($id, $name, $values, $default = '')

The passed object with the multiple properties for the radio elements must contain and . The passed default value
will be selected according to the value.

$genders = array(
(object) array('id' => 1, 'name' => 'Mnnlich'),
(object) array('id' => 2, 'name' => 'Weiblich'),
);
$this->form_builder->radio('gender', 'Geschlecht', $genders, 2);

Option

option($id, $name, $values, $default = '', $class = 'input-large')

$countries = array(
(object) array('id' => 1, 'name' => 'Schweiz'),
(object) array('id' => 2, 'name' => 'Deutschland'),
(object) array('id' => 3, 'name' => 'sterreich'),
);
$this->form_builder->option('country', 'Land', $countries, 1);

4 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

Date

date($id, $name, $default = '', $class = 'input-large', $placeholder = 'TT.MM.JJJJ')

This element requires the javascript library of bootstrap.

jQuery implementation: https://github.com/eternicode/bootstrap-datepicker

$this->form_builder->date('birthdate', 'Geburtstag');

Textarea

textarea($id, $name, $default = '', $class = 'input-xlarge', $rows = 5)

additional parameters:

rows: amount of rows

$this->form_builder->textarea('payment_remark', 'Bemerkung', 'default');

5 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

Checkbox

checkbox($name, $id, $value = '', $default = '', $class = '')

checkbox('Inaktiv', 'inactive', '', 1);


checkbox('Eigenschaft', 'settings', 'Inaktiv', 0);

Checkboxes

checkboxes($name, $id, $boxes, $default = '', $class = '')

The passed object with the multiple properties for the radio elements must contain and . The passed default value
will be selected according to the value. The checked entries are determined by a string separated by a .

$equipments = array(
(object) array('id' => 1, 'name' => 'TV'),
(object) array('id' => 2, 'name' => 'Mikrowelle'),
(object) array('id' => 3, 'name' => 'Khlschrank'),
);
$this->form_builder->checkboxes('Ausstattung', 'equipment', $equipments, '1,3');

6 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

Single Button (submit)

single_button($name, $id = '', $class = '', $icon = '')

additional parameters:

icon: the bootstrap icon class (http://twitter.github.com/bootstrap/base-css.html#icons)

$this->form_builder->single_button('speichern', 'submit_id', 'btn-primary');

Button

button($id, $name, $class = '')

$this->form_builder->button('apply', 'bernehmen', 'disabled');

Hidden

hidden($id, $default = '')

$this->form_builder->button('contact_id', '55');

7 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

translates into:

<input type="hidden" id="contact_id" value="55" />

Utility

Separation

add_separation();

This will add a little gap between two following elements. As seen in the example code, the add_separation must be called
one element before the actual break happens.

$this->form_builder->text('monthly', 'per Monat', 0, 'span6', '', '', 'CHF');


$this->form_builder->text('weekly', 'per Woche', 0, 'span6', '', '', 'CHF');
$this->form_builder->add_separation();
$this->form_builder->text('daily', 'per Tag', 0, 'span6', '', '', 'CHF');
$this->form_builder->text('additional_cost', 'Sonstiges', 0, 'span6', '', '', 'CHF');

Editable

8 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

set_editable($value);

additional parameters:

value: boolean

This makes the following form elements editable or non-editable.

Multi Form Elements


This is rather powerful, that's why it has its own section. Basically it combines all the before listed parameters and put them
together. You can have as many form elements in a row as you like, you just have to keep the array parameters appropriately.

multi($ids, $name, $types, $default = array(), $class = array(), $param = array(), $prepend = array(), $append = array())

$this->form_builder->multi(
array('phone_area', 'phone'),
'Vorwahl / Telefon',
array(Form_builder::$TYPES->TEXT, Form_builder::$TYPES->TEXT),
array('555', '123456'),
array('span3', 'span7')
);

Types

Form_builder::$TYPES = (object) array(


'TEXT' => 1,

9 of 10 5/4/2017 11:14 PM
GitHub - zwacky/codeigniter_form_builder: CodeIgniter library to build uniform form element... https://github.com/zwacky/codeigniter_form_builder

'OPTION' => 2,
'CHECKBOX' => 3,
'DATE' => 4,
'RADIO' => 5,
'BUTTON' => 6,
'PASSSWORD' => 7,
);

2017 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub API Training Shop Blog About

10 of 10 5/4/2017 11:14 PM

Das könnte Ihnen auch gefallen