我在表单加载时收到此错误:
“Flipbook”上的未知记录属性/相关组件“标题”
问题是......我不知道“标题”来自哪里。我已将其设置为career_title
架构和数据库。模型已构建,基类正确。
这是我的行动:
public function executeEdit(sfWebRequest $request)
{
if (get_class($this->getRoute()) == 'sfDoctrineRoute') {
/* edit action */
$flipbook = $this->getRoute()->getObject();
}
else {
/* add action */
$flipbook = new Flipbook();
}
$this->form = new FlipbookForm($flipbook);
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter('flipbook'));
if ($this->form->isValid()) {
$this->form->save();
$this->getUser()->setFlash('message_success', 'Flipbook saved');
return $this->redirect('@flipbook_edit?id=' .
$this->form->getObject()->get('id') .
($request->getParameter('preview') ? '&preview=1' : ''));
}
}
}
如果我从中删除$flipbook
变量 $this->form = new FlipbookForm($flipbook);
,我会得到一个成功呈现的表单,但我需要对象数据来重新填充输入字段。
我只是不知道为什么它会在对象上找到“标题”。我没有在任何地方引用它(我不认为)。有任何想法吗?错别字?建议?
让我知道是否需要提供更多代码。
这是添加的类的yml 模式:
Generic:
actAs: [ Timestampable ]
columns:
updated_by: { type: integer }
created_by: { type: integer }
published: { type: boolean, default: 0 }
relations:
creator:
class: sfGuardUser
foreignAlias: created_users
local: created_by
onDelete: "SET NULL"
last_updater:
class: sfGuardUser
foreignAlias: updated_users
local: updated_by
onDelete: "SET NULL"
flipbook:
url: /flipbook
param: { module:
Flipbook:
tableName: flipbook
inheritance:
extends: Generic
type: concrete
columns:
career_title: { type: string(255) }
career_associations: { type: clob }
skills: { type: string(255) }
skills_associations: { type: clob }
program: { type: string(255) }
program_associations: { type: clob }
draft_id: { type: integer(10) }
最后是模板,如果你需要的话:
<?php echo $form->renderFormTag(url_for($form->getObject()->isNew() ? '@flipbook_add' : ('@flipbook_edit?id=' . $form->getObject()->get('id'))), array('method' => 'post', 'id' => 'edit_form', 'name' => 'edit_form', 'class' => 'generic_form job_form')) ?>
<?php echo $form['id'] ?>
<div class="content-box">
<div class="box-body">
<div class="box-header clear">
<h2>Flipbook</h2>
</div>
<div class="box-wrap clear" style="display: block;">
<?php echo $form ?>
</div><!-- end of box-wrap -->
</div> <!-- end of box-body -->
</div>
<div class="buttons_row right main_actions">
<?php include_partial('global/apply_changes_button', array('form' => $form)) ?>
<?php include_partial('global/publish_button', array('form' => $form)) ?>
</div>
</form>
<?php include_partial('global/preview', array('form' => $form)) ?>
路由:
flipbook, action: index }
flipbook_add:
url: /flipbook/add
param: { module: flipbook, action: edit }
flipbook_edit:
url: /flipbook/edit/:id
param: { module: flipbook, action: edit }
param: { module: flipbook, action: edit }
class: sfDoctrineRoute
options: { model: Flipbook, type: object }
requirements:
id: \d+
sf_method: [get, post]
堆栈跟踪:
stack trace at () in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record/Filter/Standard.php line 55 ...
public function filterGet(Doctrine_Record $record, $name)
{
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property
/ related component "%s" on "%s"', $name, get_class($record)));
}
}
更新:
这仍然没有真正解决,所以我想保持开放一段时间,看看是否有人可以诊断问题。我解决它的方法是在架构中更改career_title
为。title
我重建了模型和表格,一切正常。关于为什么会发生这种情况的任何进一步说明都将有益于事业。