我有一个像这样的控制器。它有比列出的数组更多的数组:
$this->data['password'] = array(
'name' => 'password',
'id' => 'password',
'type' => 'password'
);
$this->data['password_confirm'] = array(
'name' => 'password_confirm',
'id' => 'password_confirm',
'type' => 'password'
);
使用phil sturgeon模板将此数据传递给视图,如下所示:
$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
谁能告诉我什么错? P.S使用codeingniter hmvc,phil sturgeon模板和ben edmunds ion auth ....
答案 0 :(得分:0)
我做了类似以下的事情来解决这个问题:
$this->data = (array) $this->data;
并将其放在$this->template->build()