How to create form in CodeIgniter

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 from  helper in the autoload.php is that if you have multiple form 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 from

$action (string) : Main controller

$attributes (array) : HTML attributes like name, class etc.

For ex :

This will produce

How to create input text field 

This will produce

How to create 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 value

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 resetbutton

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)

View Demo

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

 

 

Anuj Kumar

I'm Anuj kumar a web developer with 4+ year experience .I write blogs in my free time. I love to learn new technologies and share with others. I founded PHPGurukul in September 2015. The main aim of this website to is provide php , jquery , mysql , phpoops and other web development tutorials. I am trying best effort to make PHPGurukul useful for every single moment spend on this website. If you think this website is useful to visit please share with your friend and buddies.

Recommended Tutorials for you

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *