wwwision/form-multifileupload

示例包,为Neos.Form框架提供简单的MultiFileUpload元素

1.1.0 2020-01-14 14:54 UTC

This package is auto-updated.

Last update: 2024-09-04 15:23:19 UTC


README

示例包,为Neos.Form框架提供简单的MultiFileUpload元素。

免责声明

此包不打算在生产环境中使用,而是作为基础实现。请随意复制(部分)实现并调整以满足您的需求。

使用方法

如上所述,此包旨在作为灵感和源代码。当然,如果您想尝试它,也可以直接安装。

  1. 通过以下命令安装包:composer require wwwision/multifileupload
  2. 将新元素的配置添加到表单预设中
Neos:
  Form:
    presets:
      'default':
        formElementTypes:
          'Wwwision.Form.MultiFileUpload:MultiFileUpload':
            superTypes:
              'Neos.Form:FormElement': true
            implementationClassName: Wwwision\Form\MultiFileUpload\FormElements\MultiFileUpload
            properties:
              allowedExtensions:
                - pdf
                - doc

3a. 在表单工厂中包含元素

    public function build(array $factorySpecificConfiguration, $presetName) {
        $formConfiguration = $this->getPresetConfiguration($presetName);
        $form = new FormDefinition('someForm', $formConfiguration);

        $page1 = $form->createPage('page1');

        // ...

        $files = $page1->createElement('files', 'Wwwision.Form.MultiFileUpload:MultiFileUpload');
        $files->setLabel('Some Files');

        return $form;
    }

3b. 或在表单定义文件中

type: 'Neos.Form:Form'
identifier: someForm
label: 'Some Form'
renderingOptions:
  submitButtonLabel: 'Send'
renderables:
  - type: 'Neos.Form:Page'
    identifier: page1
    renderables:
      - type: 'Wwwision.Form.MultiFileUpload:MultiFileUpload'
        identifier: files
        label: 'Some Files'