我正在尝试使用锂框架(0.10)编写一个编辑表单。我使用 MySQL 作为 DBMS。控制器如下所示:
public function edit() {
$success = false;
$data = Posts::find(42);
return compact('data');
}
视图文件:
<?=$this->form->create(); ?>
<?=$this->form->field('title');?>
<?=$this->form->field('body', array('type' => 'textarea'));?>
<?=$this->form->submit('Add Post'); ?>
<?=$this->form->end(); ?>
<?php if ($success): ?>
<p style="color: red;">Post Successfully Saved</p>
<?php endif; ?>
调用站点时收到此错误消息:
Fatal error: Cannot use object of type lithium\data\entity\Record as array in /var/www/web/frameworks/lithium-0.10/app/resources/tmp/cache/templates/template_views_posts_edit.html_483_1313415231_358.php on line 2
我究竟做错了什么?在锂中构建编辑表单的正确方法是什么?不幸的是,官方锂文档中没有这方面的信息。