How to create form in CodeIgniter

0

- Advertisement -

For working with form in CodeIginter you have to use form helper.
Load the form helper

You can also load the form helper in application/config/autoload.php.

Benefit of loading form  helper in the autoload.php is that if you have multiple forms then you have to use form helper in every controller but loading form helper in autoload.php  then no need to load form helper in every controller. It will automatically autoload in every controller.
How to start a form

$action (string) : Main controller
$attributes (array) : HTML attributes like name, class etc.
For ex :

This will produce

How to create an input text field 

This will produce

How to create a password text field 

This will produce

How to create drop-down list

name : Name of the drop-down list
$options : list of the dropdowns
$selectedvalues :  If you wish to be selected a value
Ex for dropdwon list : 

This will produce like

If you wish to a selected one value

This will produce like

If you wish to  selected multiple values

This will produce like

How to create radio button

$data (array) : Field  data
$values (string) : Field  value
$checked : whether this radio button being checked
$extras :  Extra attributes
Ex :

This will produce like

How to create checkbox

$data (array) : Field  data
$values (string) : Field  value
$checked : whether this check box being checked
$extras :  Extra attributes
Ex :

This will produce like

How to create textarea

This will produce like

How to create submit button

This will produce like

How to create the reset button

This will produce like

How to close a form
form_close function used to close form.

Full-Form scripts

First load form helper in application/config/autoload.php.

then create a controller  (Signupform.php)

Now to form view(signup_form.php)

CodeIgniter Form (Download Script)
Size: 2.60 MB
Version: 1

- Advertisement -

Leave A Reply

Your email address will not be published.