doctrine-orm - Symfony4 存储在具有关系的会话实体中
问题描述
我有一个多步骤表单,需要将我的实体存储在会话中。问题是实体具有关系,当我从会话中检索它时,关系属性正在消失(空)。
我知道我可以序列化实体并反序列化它,但它有很多检查/代码有很多关系......
public function route1(Session $session, ....)
{
$entity = new Entity();
$form = $this->createForm(EntityType::class, $entity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$session->set('entityData', $entity);
dump($session->get('entityData')); // Here it's fine, nested attributes are still set
return $this->redirectToRoute('route2');
}
}
public function route2(Session $session)
{
$entity = $this->em->merge($session->get('entityData'));
dump($entity, $entity->getCustomer()->getFistname()); // And here all nested attributes are null like on the image ...
}
解决方案
推荐阅读
- microsoft-graph-api - 为什么当我的 MS Graph API 邮件搜索未找到任何结果时,我会收到网关超时?
- html - 在输入字段 HTML 中来自 OTP SMS 的自动填充代码,例如在 Safari 中
- reactjs - 如何将部分逻辑转移到另一个文件
- flutter - 参数类型“bool”不能分配给参数类型“voidcallback()”
- python-3.x - 如何将一个元组列表中的第一个元组与另一个列表中的第一个元组进行比较,然后将第二个元组与第二个列表进行比较,依此类推?
- php - 如何在php中以正确的方式获取count(*)
- python - 如何更新和同步所有工作人员的任务和代码
- c++ - enable_if + std::less + sizeof... 的组合使 MSVC 失败
- azure - 在 docker 容器上写入文件时权限被拒绝错误
- python - 如何使用openpyxl读取python中的合并单元格?