PHP code example of tuhin18003 / codeigniter-form-builder
1. Go to this page and download the library: Download tuhin18003/codeigniter-form-builder library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tuhin18003 / codeigniter-form-builder example snippets code
public function index()
{
$this->load->helper('form');
$form = new \Cs_form\Cs_form();
$bootstrap = $form->Bootstrap();
$inputs = $bootstrap->generate_basic_form(array(
'action' => 'test',
'attributes' => array( 'class' => 'formclass', 'id' => 'myform' ),
'fields' => array(
array(
'type' => 'text',
'label' => array( 'text' => 'What is your Name', 'id' => 'username', 'attribute' => array( 'class' => '')),
'input' => array(
'name' => 'username',
'id' => 'username',
'value' => 'johndoe',
'class' => 'form-control'
)
)
)
));
$this->load->view( 'welcome_message', array( 'inputs' => $inputs ) );
}
code
$inputs = $bootstrap->generate_inline_form(array(
'action' => 'test',
'attributes' => array( 'id' => 'myform' ),
'fields' => array(
array(
'type' => 'text',
'label' => array( 'text' => 'What is your Name', 'id' => 'username', 'attribute' => array( 'class' => '')),
'input' => array(
'name' => 'username',
'id' => 'username',
'value' => 'johndoe',
'class' => 'form-control'
)
)
)
));
code
$inputs = $bootstrap->generate_horizontal_form(array(
'action' => 'test',
'attributes' => array( 'id' => 'myform' ),
'fields' => array(
array(
'type' => 'text',
'label' => array( 'text' => 'What is your Name', 'id' => 'username', 'attribute' => array( 'class' => 'col-sm-2 control-label')),
'input' => array(
'name' => 'username',
'id' => 'username',
'value' => 'johndoe',
'class' => 'form-control',
'input_wrap_class' => 'col-sm-10'
)
)
)
));