mapseven / neos-formbundle
Neos CMS 表单功能的扩展包
1.0.0
2019-01-14 18:44 UTC
Requires
- flowpack/elasticsearch: *
- neos/flow: ^4.0 || ^5.0 || dev-master
- neos/form: *
This package is not auto-updated.
Last update: 2024-09-14 18:58:40 UTC
README
此扩展包包含与Neos CMS中的Neos.Form包一起工作的各种功能
安装
composer require mapseven/neos-formbundle
功能
- 持久化完成器 - 将提交的formData存储在存储库和/或ElasticSearch中
用法
此包仅包含您可以在包中使用的完成器和助手。您可以在FormBundleDemo中找到示例
持久化完成器
只需将以下完成器添加到form.yaml
#... finishers: 'MapSeven.Neos.FormBundle:Persistence': identifier: 'MapSeven.Neos.FormBundle:Persistence' options: db: true elasticSearch: false
持久化完成器的默认选项如上例所示。根据您的需求进行更改。
从节点类型设置中覆盖配置
通过向节点类型配置中添加选项,您可以覆盖form.yaml
中的选项
将您想要覆盖的属性添加到NodeTypes.yaml
'MapSeven.Neos.FormBundleDemo:Form': superTypes: 'Neos.NodeTypes:Form': true ui: label: Demo Form icon: 'icon-envelope-alt' inspector: groups: persistenceOptions: label: Persistence Options position: 40 properties: #... db: type: boolean defaultValue: true ui: label: Repository inspector: group: persistenceOptions elasticSearch: type: boolean defaultValue: false ui: label: Elastic Search inspector: group: persistenceOptions
通过在form.html
模板中从节点类型设置覆盖配置
{namespace formBundle=MapSeven\Neos\FormBundle\ViewHelpers} <div{attributes -> f:format.raw()}> <f:if condition="{formIdentifier}"> <f:then> <formBundle:render persistenceIdentifier="{formIdentifier}" presetName="{presetName}" overrideConfiguration="{finishers: {'MapSeven.Neos.FormBundle:Persistence': {options: {db: node.properties.db, elasticSearch: node.properties.elasticSearch}}}}" /> </f:then> <f:else> <p>Please select a valid Form identifier in the inspector</p> </f:else> </f:if> </div>
注意:此示例使用了一个调整过的表单视图助手,在form.yaml
不包含该完成器配置的情况下将取消完成器
ElasticSearch映射
此包使用Flowpack/Elasticsearch包将FormData索引到ElasticSearch中。这意味着您可以使用该包的设置和其他功能。请查看Settings.yaml
以获取示例分析器配置,我用于分面搜索。除此之外,您还可以在form.yaml
中以类似方式为每个表单项定义映射和转换器。
#... renderables: - type: 'Neos.Form:MultipleSelectCheckboxes' identifier: category label: 'Categories' properties: elementClassAttribute: 'checkbox' elementErrorClassAttribute: 'state-error' containerClassAttribute: '' options: cat1: Category 1 cat2: Category 2 cat3: Category 3 elasticSearch: mapping: type: string analyzer: string_lowercase fields: raw: type: string index: not_analyzed
许可证
Neos FormBundle根据MIT许可证授权