1

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?

2 Answers 2

5

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

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

Sign up to request clarification or add additional context in comments.

Comments

3

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

1 Comment

Sidenote @Mert METIN if you intend to use the form_validation library, you don't need to load form helper again as it is already "included"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.