php form_open() 在 codeigniter 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14118170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 06:42:02  来源:igfitidea点击:

form_open() not working in codeigniter

phpformscodeigniter

提问by Nitish

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

我正在尝试在 CodeIgniter 中构建一个简单的表单。我的 VIEW 'input_view.php' 是:

 <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?

但是当我尝试时http://localhost/CodeIgniter/index.php/books/input,它不显示表单,而是显示 page upto menu。这里有什么问题?

回答by Vinoth Babu

Did you load form helper in your controller where you call your simple form view?????

您是否在控制器中加载了表单助手,在那里您调用了简单的表单视图????

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

回答by prasobh

You must load helper file form for form usage on codigniter like this.

您必须像这样在 codgniter 上加载辅助文件表单以供表单使用。

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

回答by Reinstar

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

请参阅CodeIgniter User Guide,您必须先加载表单助手,然后才能这样做

$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.

在使用 form_open、form_input 或其他任何东西之前,您可以将该语法放在控制器上或视图顶部。

回答by tanmay mohanty

$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