[英]How to pass data to the view in codeigniter?
我有一个像这样的控制器。 它比这里列出的数组更多:
$this->data['password'] = array(
'name' => 'password',
'id' => 'password',
'type' => 'password'
);
$this->data['password_confirm'] = array(
'name' => 'password_confirm',
'id' => 'password_confirm',
'type' => 'password'
);
使用phil using鱼模板将这些数据传递到视图,如下所示:
$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,phil urge鱼模板和ben edmunds ion auth ....
我做了类似以下的事情来解决这个问题:
$this->data = (array) $this->data;
并将其放在$this->template->build()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.