In CodeIgniter the Form helper is assist to right working with form. Form helper show you form in your web page, without Form Helper you can’t show the form in web page.
Set the Form helper in your Controller parent construct, which controller shows the form view page in your project file. The Form Helper example code is given to you in below.
$this->load->helper(‘form’);
You can use HTML from or CODEIGNITER form but you must need Helper in your CODEIGNITER Project. This tutorial I will show you, How to use CODEIGNITER Form in the WEB services.
There is a example to use helper under Parent Construct. Follow the code
public function __construct(){ parent::__construct(); $this->load->helper('form'); }
In CODEIGNITER we are use many helper for helping Project. We need helper in CODEIGNITER web service, without helper there will show many problem I the project that stop to run your project. That’s like
$this->load->helper(‘url’);
This helper use for URL help when you access URL or click another menu then you need this helper it assist to go to next URL.
The Form helper is help to you to show the form in the web page of CODEIGNITER. Now I will show you to use CODEIGNITER form in page. Everybody use HTML Form in the web page and use form tag that is <form> </form>. But CODEIGNITER form have no starting or ending tag here to show the form use open form and close form.
The start the form use echo form_open () and close the form use echo form_close() in CODEIGNITER. Then get input field under the form use echo form_input() or you can use HTML input field in here.
There have many examples I will show you.
Example 1:
<?php $par=array('class'=>'smart-form','id'=>'form'); echo form_open('set action',$par); ?> <input type="text" class="form-control" name="name"> <?php echo form_close(); ?>
There some parameters store in a variable then set the variable in the form and set action in the form and use html input filed now close the form.
Example 2:
<?php $par=array('class'=>'form-control','id'=>'form'); echo form_open('Welcome/signup',$par); ?> <input type="text" class="form-control" name="name"> <?php echo form_close(); ?>