Mert METİN
Mert METİN

Reputation: 1288

Codeigniter - forms

I'm new to CodeIgniter and try to understand how to create forms. I searched both on the Net and stackopverflow but did not reach anything.

What i want is to create forms with helpers. In order to do that in my controller create a function, named formElements() and the code is

public function formElements()
        {
            $this->load->helper(array('form'));
        }

and in kayit.php

i try to create some html elements

<?=form_open('kayit/formElements')?>
    <?=form_fieldset('Login Form')?>

        <div class="textfield">
            <?=form_label('username', 'user_name')?>
            <?=form_input('user_name')?>
        </div>

        <div class="textfield">
            <?=form_label('password', 'user_pass')?>
            <?=form_password('user_pass')?>
        </div>

        <div class="buttons">
            <?=form_submit('login', 'Login')?>
        </div>

    <?=form_fieldset_close()?>
<?=form_close();?>

However i take the error : Fatal error: Call to undefined function form_open() in C:\xampp\htdocs\pasaj\application\views\kayit.php on line 220

why?

Upvotes: 1

Views: 4046

Answers (2)

Code Prank
Code Prank

Reputation: 4250

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

$autoload['helper'] = array('form');

Upvotes: 5

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100205

You can include the form helper in your Controller's constructor function, like:


$this->load->helper('form');

And it should work fine in view. Ref: Form Helper Hope it helps

Upvotes: 3

Related Questions