typo3 - 在自己的viewhelper中使用外国模型作为参数
问题描述
从流体中,我称我的 viewhelper 类 <ext:thehelper adr="{adr}" /> {adr} 是 tt_address → FriendsOfTYPO3\TtAddress\Domain\Model\Address 的数组
在viewhelper中我注册了参数
use FriendsOfTYPO3\TtAddress\Domain\Model\Address;
public function initializeArguments() {
$this->registerArgument('adr', 'FriendsOfTYPO3\TtAddress\Domain\Model\Address', 'the addresses', true);
}
失败并显示此消息:参数“adr”已注册为“FriendsOfTYPO3\TtAddress\Domain\Model\Address”类型,但在视图助手中属于“TYPO3\CMS\Extbase\Persistence\Generic\QueryResult”类型
如何接收要使用的 adr-array。谢谢您的帮助!
解决方案
如果您的 VH 必须接受多个地址,那么您的 ViewHelper 参数不得将查询结果中包含的任何对象的类名注册为数据类型。
相反,您必须使用 type 注册参数TYPO3\CMS\Extbase\Persistence\Generic\QueryResult
。
推荐阅读
- python-3.x - tensorflow.keras.layers:ImportError:无法导入名称“CuDNNLSTM”
- javascript - 在 React 中对组件进行更改时,开发服务器不会自动刷新
- ruby-on-rails - 使用 Capybara 和 Selenium 记录删除测试失败
- angular - get selected file size, from chooser plugin Cordova/Ionic
- django - 我有这个错误 - jquery.min.js: 2 Uncaught TypeError: Illegal invocation django
- scikit-learn - 使用 Julia 中的 Scikit Learn 预编译创建系统映像
- flutter - 检查属性是否存在于 json
- go - 动态和/或递归地读取和合并两个 Yaml 文件
- javascript - 从多个单选组中随机选择单选按钮
- servlets - 错误 404 请求的资源 [/Project-Name/] 不可用,Servlet 错误,