rkw/rkw-form

表单管理扩展

安装: 219

依赖项: 0

建议者: 0

安全性: 0

星星: 0

关注者: 2

分支: 0

开放问题: 0

类型:typo3-cms-extension


README

它做什么?

其主要目的是表单管理。一方面,它提供简单的表单,没有更大的上下文(类似于Ext FormFramework)。另一方面,它准备在未来通过一些特殊功能扩展FormFramework。

ExtForm框架基本配置

可用的cron作业

RkwForm: FileCleanup

  • 由于“删除上传”邮件结束器仅清除成功发送的表单的上传,我们需要一个cron作业来清除上传文件夹
  • 参数: "daysFromNow" - 定义应删除哪些旧文件。默认值:30(天)
  • 在此处更改或添加FormFrameworkConf.yaml中的上传目标:TYPO3.CMS.Form.persistenceManager.allowedFileMounts
  • 有意限制:cron作业处理多个文件挂载。条件:文件路径必须包含字符串“tx_rkwform”

RkwForm: Cleanup

  • 删除过期的记录

RkwForm: Security

  • 如果给定的上传文件夹不存在htaccess保护,cron作业应该创建一个。查看“securityCheck”方法

纳入的基本ExtForm的更改/改进

  • HTML5验证已禁用(无样式可用)
  • 将基于bootstrap的“ViewGrid”替换为每个字段的简单宽度属性
  • 独立的表单错误消息
  • h1-h6选项用于静态文本字段
  • 复选框字段具有“type”属性,可将其用作条款复选框。与扩展FeRegister绑定
  • 每个E-Mail的独立问候语文本(查看特定表单的邮件结束器)
  • 邮件与扩展Postmaster绑定,以便为每个E-Mail使用标题、页脚及其组件(图像;链接)
  • 注意:ExtForm的EmailFinisher已被/rkw_form/Classes/Domain/Finishers/EmailFinisher.php覆盖
  • 提示:要使用与这里相同的YAML-reader与单独的表单配置一起工作,您可以使用/rkw_form/Classes/ViewHelpers/GetFinisherOptionViewHelper.php

提示

  • 对于FE(fluid)翻译使用“locallang.xlf”
  • 对于BE(yaml)翻译使用“form_framework.xlf”
  • 要了解如何编辑所有FormExt表单的基本内容或其字段,请查看FormFrameworkConf.yaml文件。此文件定义所有基本内容
  • 要编辑您想要显示为内容元素的特定表单,您应该使用后端模块“表单”。但您也可以直接通过/rkw_forms/configuration/Yaml/Forms/YourForm进行更改
  • 提示:直接在yaml中更改的表单定义可以在保存给定表单时在TYPO3后端直接覆盖

添加新表单(不使用FormFramework)

  • 您需要了解的信息:一个表单是一个插件。仅当您需要进一步说明时才显示以下内容

创建不扩展表单数据库表的新表单

  • ext_localconf: 创建新的表单插件。下面我们还将创建必要的“ExampleController”
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'RKW.RkwForm',
    'ExampleForm',
    [
        'ExampleForm' => 'new, create'
    ],
    // non-cacheable actions
    [
        'ExampleForm' => 'new, create'
    ]
);
  • TCA/override/tt_content:注册新的表单插件
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    'RKW.RkwForm',
    'ExampleForm',
    'RKW Form: Example Formular'
);
  • TCA/override/tt_content:使用标准的 flexform。只需将您的插件名称添加到数组中
$pluginList = ['StandardForm', 'ExampleForm'];
  • 控制器:创建一个新的控制器,它扩展了 AbstractFormController(用于可能的单独用途)
class ExampleFormController extends \RKW\RkwForm\Controller\AbstractFormController
  • 控制器:添加 createAction 并调用父级的 "createAbstractAction",因为 AbstractController 无法通过 AbstractEntity 直接处理单个表单内容(缺少 getter & setter)
/**
 * action create
 *
 * @param \RKW\RkwForm\Domain\Model\StandardForm $standardForm
 * @param int $privacy
 * @TYPO3\CMS\Extbase\Annotation\Validate("RKW\RkwForm\Validation\Validator\AbstractFormValidator", param="standardForm")
 * @return void
 */
public function createAction(BstForm $standardForm, $privacy = 0): void
{
    // my example code, which is different to the createActractAction of the AbstractController

    parent::createAbstractAction($standardForm, $privacy);
}
  • TypoScript:在 CONSTANTS & SETUP 中定义您插件的单个必填字段
  • 提示:SK 改变了逻辑。您必须为每个表单创建一个自己的验证器
// ####################
// ExampleForm
// ####################
plugin.tx_rkwform_exampleform < plugin.tx_rkwform
plugin.tx_rkwform_exampleform {
    settings {
        mandatoryFields {
            standard = {$plugin.tx_rkwform_exampleform.settings.mandatoryFields.standard}
        }
    }
}
  • 资源:创建您个人的模板和部分
  • 验证:除非您有一些特殊需求,否则您永远不需要重写 AbstractFormValidator
  • 邮件:除非您有一些特殊需求,否则您永远不需要重写、扩展或更改基于 PHP 的邮件部分

扩展:如果您需要扩展表单表

  • ext_tables.sql:如有必要,扩展表单字段。请在检查是否标准表单字段已经足够后再进行操作
#
# extend for exampleForm
#
CREATE TABLE tx_rkwform_domain_model_standardform (
  exmpl1 int(11) DEFAULT '0' NOT NULL,
  exmpl2 int(11) DEFAULT '0' NOT NULL,
  exmpl3 int(11) DEFAULT '0' NOT NULL,
  exmpl4 tinyint(4) unsigned DEFAULT '0' NOT NULL,
);
  • TCA:通过覆盖 TCA/Overrides/tx_rkwform_domain_model_standardform 添加内容
class ExampleForm extends \RKW\RkwForm\Domain\Model\StandardForm
  • 模型:创建模型
class ExampleForm extends \RKW\RkwForm\Domain\Model\StandardForm
  • 仓库:创建仓库
class ExampleFormRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
  • 本地化语言:创建所有必要的语言内容(包括表单错误!)
  • BE
<!-- example extend -->
<trans-unit id="tx_rkwform_domain_model_standardform.exmpl1">
    <source>Number 1</source>
    <target>Pers. Zahlenkomb. 1</target>
</trans-unit>
<trans-unit id="tx_rkwform_domain_model_standardform.exmpl2">
    <source>Number 2</source>
    <target>Pers. Zahlenkomb. 2</target>
</trans-unit>
<trans-unit id="tx_rkwform_domain_model_standardform.exmpl3">
    <source>Number 3</source>
    <target>Pers. Zahlenkomb. 3</target>
</trans-unit>
<trans-unit id="tx_rkwform_domain_model_standardform.exmpl4">
    <source>Agree</source>
    <target>Zustimmung </target>
</trans-unit>

<!-- example extend -->
<trans-unit id="tx_rkwform_domain_model_standardform.tabs.bst">
    <source>Example</source>
    <target>Beispiel</target>
</trans-unit>
<trans-unit id="tx_rkwform_domain_model_standardform.palettes.bst">
    <source>Example</source>
    <target>Beispiel</target>
</trans-unit>
  • FE
<trans-unit id="form.error.newFormRequest.exmpl1">
    <source>Number combination 1</source>
    <target>Zahlenkombination Feld 1</target>
</trans-unit>
<trans-unit id="form.error.newFormRequest.exmpl2">
    <source>Number combination 2</source>
    <target>Zahlenkombination Feld 2</target>
</trans-unit>
<trans-unit id="form.error.newFormRequest.exmpl3">
    <source>Number combination 3</source>
    <target>Zahlenkombination Feld 3</target>
</trans-unit>
<trans-unit id="form.error.newFormRequest.exmpl4">
    <source>Message</source>
    <target>Nachricht</target>
</trans-unit>

  • 电子邮件:请注意,此表单扩展主要通过与电子邮件一起使用。因此,请将您的新字段添加到 /ext/rkw_form/Resources/Private/Partials/Email/Details.html