2014-12-04 60 views
2

我试图使用form_helper.php一个辅助类笨2.2.0 和下面是它给了错误,当我尝试这样做:笨2.2.0 form_helper给人错误

控制器文件

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

视图文件

<?php 
    $attributes = array('class' => 'form-horizontal', 'id' => 'admin-form'); 
    echo form_open($this, $attributes); 
?> 

错误:

A PHP Error was encountered

Severity: Warning

Message: strpos() expects parameter 1 to be string, object given

Filename: helpers/form_helper.php

Line Number: 53

A PHP Error was encountered

Severity: 4096

Message: Object of class CI_Loader could not be converted to string

Filename: helpers/form_helper.php

Line Number: 61

Although it does print the tag.

What I could be doing wrong here ?

+2

form_open($ this,$ attributes)是我想的问题。第一个参数应该是您要链接到的控制器方法。 – Craig 2014-12-04 12:57:00

回答

2

您的代码:

echo form_open($this, $attributes); 

是,正确的。它正确的:

echo form_open($YOUR_FORM_ACTION, $attributes); 

Reference

问题正在发生,因为,你是路过$this,一个对象,而不是形式的行动(串)。

2

您不能使用$this作为第一个参数,因为它是内部CI对象。尝试:

echo form_open('controller/method', $attributes);