wwwision/form-multicolumnsection

具有自定义 Flow Form Framework Form Element 的流程包,该 Element 可以渲染多列

1.1.2 2023-08-01 15:10 UTC

This package is auto-updated.

Last update: 2024-08-30 01:26:01 UTC


README

此包向 default 预设添加了一个新的表单元素 Wwwision.Form.MultiColumnSection:TwoColumns,允许在 Flow Form Framework 的表单中渲染多列部分。

它包括

  • Settings.yaml 中的表单框架元素定义,包括相应的自定义 PHP 实现
  • neos/form-builder 一起工作的融合和节点类型定义
  • 一个 Fluid 模板,当使用默认的 FluidFormRenderer 渲染表单时将使用它
  • 一个 Fusion 原型,当使用 neos/form-fusionrenderer 渲染表单时将使用它

用法

使用 GIT 安装此包

git clone https://github.com/bwaidelich/Wwwision.Form.MultiColumnSection.git Packages/Application/Wwwision.Form.MultiColumnSection

并确保重新扫描已安装的包,以便正确安装

./flow flow:package:rescan

注意:此包需要版本 4.0 或更高版本的 neos/form

在 Neos 表单构建器中的用法

在 Neos 后端中,现在有一个新的内容元素类型,可以添加到基于节点的表单中

Create Wizard

当插入时,可以将子元素添加到 column1Elementscolumn2Elements 表单元素集合中。

从 Fusion 的用法

此表单元素也可以这样从 Fusion 中使用

prototype(Some.Package:SomeForm) < prototype(Neos.Form.Builder:Form) {
    presetName = 'somePreset'
    firstPage {
        elements {
            twoCols = Wwwision.Form.MultiColumnSection:TwoColumns.Definition {
                label = 'Name and Email'
                column1Elements {
                    name = Neos.Form.Builder:SingleLineText.Definition {
                        label = 'Name'
                    }
                }
                column2Elements {
                    email = Neos.Form.Builder:SingleLineText.Definition {
                        label = 'Email'
                        validators {
                            emailAddress = Neos.Form.Builder:EmailAddressValidator.Definition
                        }
                    }
                }
            }
        }
    }
}

在 YAML 表单定义中的用法

YAML 表单定义的结构是严格的,因此不允许使用自定义键,如 column1Elements。相反,列分配是通过自定义 renderingOption "_column" 完成的

type: 'Neos.Form:Form'
identifier: some-identifier
renderables:
    -
        type: 'Neos.Form:Page'
        identifier: page1
        renderables:
            -
                type: 'Wwwision.Form.MultiColumnSection:TwoColumns'
                identifier: two-columns
                label: 'Two Columns'
                renderables:
                    -
                        type: 'Neos.Form:SingleLineText'
                        identifier: name
                        renderingOptions:
                          _column: 1
                        label: "Name"
                    -
                        type: 'Neos.Form:SingleLineText'
                        identifier: email
                        renderingOptions:
                          _column: 2
                        label: "Email"
                        validators:
                            -
                                identifier: 'Neos.Flow:EmailAddress'