b13 / otf
为FormEngine提供即时评估提示
Requires
- php: >=7.2.0
- typo3/cms-backend: ^10.4 || ^11.0
- typo3/cms-core: ^10.4 || ^11.0
Requires (Dev)
- phpstan/phpstan: ^0.12.37
- phpunit/phpunit: ^8.4
- roave/security-advisories: dev-master
- typo3/coding-standards: ^0.4.0
- typo3/testing-framework: ^6.1
README
本TYPO3扩展允许将FormEngine FieldWizard添加到特定的TCA字段。FieldWizard会检查相应字段的eval
配置。如果找到支持的评价之一或多个,FieldWizard将在后台表单中显示即时评估提示。
一个示例用例是fe_users
的username
字段,该字段配置为unqiueInPid
,因此当输入已存在的用户名时,会添加提示。
安装
通过composer req b13/otf
安装此扩展。
您还可以从TYPO3扩展存储库下载此扩展,并在您的TYPO3安装的扩展管理器中激活它。
注意:此扩展与TYPO3 v10和v11兼容。
配置
可以将FieldWizard添加到任何类型为input
的TCA字段。
以下示例将FieldWizard添加到TYPO3 fe_users
表的username
和email
字段。
<?php defined('TYPO3') or die(); \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Otf\Tca\Registry::class) ->registerFields( new \B13\Otf\Tca\Configuration('fe_users', new \B13\Otf\Tca\Field('username'), new \B13\Otf\Tca\Field('email') ) );
如果您想将FieldWizard添加到一个尚未定义任何支持评价的字段,您可以简单地向Field
添加新的评价。
<?php defined('TYPO3') or die(); \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Otf\Tca\Registry::class) ->registerFields( new \B13\Otf\Tca\Configuration('fe_users', (new \B13\Otf\Tca\Field('email'))->addEvaluations('uniqueInPid', 'email') ) );
还可以通过->removeEvaluations()
方法删除现有的评价。
以上示例用于TCA/Overrides
文件。在您自己的TCA中,只需直接将FieldWizard添加到字段的配置中即可
'aField' => [ 'label' => 'aField', 'config' => [ 'type' => 'input', 'eval' => 'trim,required,unique', 'fieldWizard' => [ 'otfWizard' => [ 'renderType' => 'otfWizard' ] ] ] ]
支持的评价
目前支持以下评价
unique
uniqueInPid
email
管理
可以通过User TSconfig配置即时评价提示的行为。以下选项可用
tx_otf.conflictingRecordLink
- 是否显示冲突记录的链接(默认:1
)
注册API
您可以注册自己的评价服务以处理额外的eval
。因此,创建一个新的实现EvaluationInterface
的评价服务类。该类将被自动标记并注册。此外,您还可以扩展已实现一些必需方法的AbstractEvaluation
。
致谢
此扩展由Oliver Bartsch于2021年创建,为Stuttgart的b13 GmbH。
查找我们为客户端项目创造价值的更多TYPO3扩展。作为我们的工作方式的一部分,我们专注于测试和最佳实践,以确保所有代码的长期性能、可靠性和结果。