简体   繁体   中英

form_open() not working in codeigniter

I am trying to build a simple form in CodeIgniter. My VIEW 'input_view.php' is:

 <html>
    <head>
        <link rel="stylesheet" type="text/css" href="<?php echo "$base/$css"?>">
    </head>
    <body>
        <div id="header">
            <?php $this->load->view('books_header'); ?>
        </div>

        <div id="menu">
            <?php $this->load->view('books_menu'); ?>
        </div>
        <?php //echo $title; ?>
        <?php echo form_open('books/input'); ?>

            <?php echo $title; ?>
            <?php echo form_input('title'); ?>;

            <?php echo $author; ?>
            <?php echo form_input('author'); ?>

            <?php echo $publisher; ?>
            <?php echo form_input('publisher'); ?>

            <?php echo $year; ?>
            <?php echo form_dropdown('year',$years); ?>

            <?php echo $available; ?>
            <?php echo form_checkbox('available','yes',TRUE); ?>

            <?php echo $summery; ?>
            <?php echo form_textarea('summery'); ?>

            <?php echo form_submit('mysubmit', 'Submit'); ?>

    <?php echo form_close(); ?>


        <div id="footer">
            <?php $this->load->view('books_footer'); ?>
        </div>
    </body>
</html>

But when I tried http://localhost/CodeIgniter/index.php/books/input , it does not show the form, instead shows page upto menu . Whats the problem here?

您是否在调用简单表单视图的控制器中加载了表单帮助程序?

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

您必须像这样在codigniter上加载供使用的辅助文件格式。

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

Refer to CodeIgniter User Guide , you must load form helper before do it like this

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

You may put that syntax on your Controller or at top of your View before you use form_open, form_input or anything else.

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

in view page

or autoload the file go to application/config/autoload

there you will find

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

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

//input from helper it will allow in both view and controller page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM