首页 文章

如何将对象从存储库加载到Typo3 6.2 Extbase Extension中的<f:form.select/>

提问于
浏览
0

首先我的具体问题: What should I do to be able to select between all doctors when creating a new appointment?

现在背景:
从Typo 4.7更新到6.2之后我遇到了一些像这样的问题:

创建新的 Appointment 时,我需要一个用户选择 Doctor 的选择字段 .
所以我这样做了:

<f:form.select property="doctor" options="{doctors}" optionLabelField="lastName" />

我的Extensionbuilder设置:
Appointment 是具有 Doctor 关系类型的实体:"n:1"
Doctor 是扩展\ TYPO3 \ CMS \ Extbase \ Domain \ Model \ FrontendUser的实体

在我的AppointmentController中,我已经把它

/**
 * doctorRepository
 *
 * @var \Vendor\Extensionname\Domain\Repository\DoctorRepository
 * @inject
 */
protected $doctorRepository = NULL;

newAction 我写道:

$doctors = $this->doctorRepository->findAll();
...
$this->view->assignMultiple(array(
           'doctors' => $doctors,
        ));

这样 no items show up 在我的选择字段中,即使我有一些类型 Doctor 的fe_users . 然后我试着通过这样做看到 $doctors 里面的内容:

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($doctors);

但它说:

Caught exception: Unknown column 'fe_users.sorting' in 'order clause'

编辑:接受的答案解决了这个问题 .

然后它显示了律师对象,但选择仍然是空的 . 我后来自己找到了这个问题的答案(参见我自己的答案) .

2 回答

  • 1

    我认为首先你需要修复缺少列的问题 . 对我来说似乎在更新TYPO3期间,删除了数据库列fe_users.sorting . 也许它没有在ext_tables.sql文件中正确定义,数据库分析器建议将其删除? TYPO3核心中不存在此类字段,因此必须先从您的或第三方扩展中添加该字段 . 请执行以下操作:

    • 如果存在fe_users.zzz_deleted_sorting,请检入数据库,如果存在,请将其名称更改为fe_users.sorting并将字段定义添加到ext_tables.sql文件中:

    sorted int(11)DEFAULT'0'NOT NULL,

    • 如果没有字段fe_users.zzz_deleted_sorting,则表示它已从数据库中删除 . 请将第1点的SQL代码添加到ext_tables.sql并使用安装工具执行数据库比较 . 它会建议你创建新的字段 - fe_users.sorting . 请创建它 .

    还请检查数据库结构中是否存在其他一些重要差异 . 数据库分析器将向您展示所有这些 .

    解决数据库问题时,如果有任何更改,请提供反馈 . 然后我们可以继续下一期 .

    编辑:

    数据库问题得到解决,因此我们可以更进一步 .

    我展示了律师对象,但选择仍然是空的

    您可能从数据库获得空响应,因为未定义storagePid . Extension Builder可能已经为您创建了TypoScript配置 . 请执行以下操作:

    • 在扩展目录中查找文件Confiugration / TypoScript / constants.txt .

    • 检查BE中创建的医生记录的页面ID .

    • 使用适当的页面ID编号填充storagePid . StoragePid位于路径中:plugin.tx_ [pluginkey] .persistence.storagePid . 它也应该由Extension Builder定义,但它的值可能是空的 .

  • 0

    我发现了问题的第二个原因:
    在我的 <f:render...> 中,我没有通过我的医生作为论点!

    ...arguments="{..., doctors:doctors}"/>
    

相关问题