php - Symfony表单视图猜错方法?
问题描述
我使用 Symfony 5,并且我创建了 3 个类 Deal、DealCategory 和 DealSubCategory php bin/console make:entity
。这些是这些类之间的关系。
这是这些课程的要点
https://gist.github.com/methodeprog/8ca704f89910284197e93cafb1f009de
然后在它们的 php bin/consolemake:crud
之后
在交易表格中,当尝试创建交易时,我得到了这个。这很奇怪,请帮忙
Neither the property "dealCategory" nor one of the methods "dealCategory()", "getdealCategory()"/"isdealCategory()"/"hasdealCategory()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".
奇怪的是,在我的 Deal 类方法中没有 getdealCategory() 而是 getDealCategory()...
为什么 Symfony 建议getdealCategory()
而不是getDealCategory()
?
解决方案
您可以添加您的 formType 文件和控制器 addAction 的代码吗?
我认为您忘记了 DealType :
$resolver->setDefaults(array(
'data_class' => 'App\Entity\Deal'
));
希望这有帮助
推荐阅读
- wxpython - 使用 wxpython 如何让我在一个 Textctrl 面板中键入的单词在另一个面板中显示为加密,反之亦然
- c++ - 在队列中选择备用位置
- ios - 如何在 Swift 中将字符串转换为日期到字符串?
- json - 如何通过 Linux 命令删除 JSON 文件中的对象
- ruby-on-rails - 为什么 Accept: application/json 和 Content-Type: application/json 会导致此测试出现问题?
- ethereum - 请求的从 literal_string 到字符串存储指针的无效隐式转换
- ag - SilverSearcher - 当文档显示“--ignore PATTERN”没有等号时,为什么我可以使用“--ignore=PATTERN”?
- spring - 在windows cmd中运行的spring boot server响应来自远程浏览器的请求但是在eclipse中运行时没有响应
- javascript - js - “阻止”或“重定向”所有键盘和鼠标滚轮动作
- c++ - 如何在没有分隔符的大文本文件中查找所有字典单词?