如何将数据传递给codeigniter中的视图?

问题描述:

我有一个这样的控制器。它有更多的阵列比这里列出:如何将数据传递给codeigniter中的视图?

$this->data['password'] = array(
    'name' => 'password', 
    'id' => 'password', 
    'type' => 'password' 
); 
$this->data['password_confirm'] = array(
    'name' => 'password_confirm', 
    'id' => 'password_confirm', 
    'type' => 'password' 
); 

这个数据传递到使用菲尔鲟模板这样的观点:

$this->template 
     ->title("Edit your Profile") 
     ->set_theme('admin') 
     ->set_layout('dashboard') 
     ->set_partial('links','partials/links') 
     ->set_partial('header','partials/header') 
     ->set_partial('menu','partials/menu') 
     ->set_partial('footer','partials/footer') 
     ->build('auth/edit_user', $this->data); 

我的视图文件是:

Password: (if changing password)<br /> 
<?php echo form_input($password);?> 

Confirm Password: (if changing password)<br /> 
<?php echo form_input($password_confirm);?> 

现在,当我刷新页面,我得到的字段中的值,但也在页面的顶部有一个错误消息:

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

谁能告诉我什么是错的? PS使用codeingniter HMVC,菲尔鲟模板和本兹离子权威性....

+1

尝试在这个问题接受的答案调试:http://*.com/questions/9758185/object-of-class-stdclass-could-not-be-converted-to-string – Natrium 2013-03-19 10:02:16

+0

,这有助于相当多的 – 2013-03-19 11:17:36

我做了类似下面的内容来解决这个问题:

$this->data = (array) $this->data;

$this->template->build()

之前把它