Ludwig
Ludwig

Reputation: 3749

How to ad data dynamically to a TYPO3 form finisher's select field (in form editor and in plugin override)

I am writing a custom form finisher for TYPO3 Forms where I want to add data to a select field that must be fetched from an external system by API.
The select field is used to configure the finisher and not to be displayed in the frontend form!

screen shot of the finisher in the form editor

Here's what I've got and what generates a static select field for the "tags".

The TypoScript Configuration loads the YAML.

plugin.tx_form.settings.yamlConfigurations {
    1499086547 = EXT:myforms/Configuration/yaml/Setup.yaml
}

module.tx_form.settings.yamlConfigurations < plugin.tx_form.settings.yamlConfigurations

The Setup.yaml looks like this:

TYPO3:
  CMS:
    Form:
      prototypes:
        standard:          
          
          finishersDefinition:
            TagFinisher:
              implementationClassName: 'Me\Myforms\Domain\Finishers\TagFinisher'

              FormEngine:
                label: "Tag Finisher"
                elements:
                  #
                  # This is the select field in the plugin that should be filled dynamically
                  #
                    label: Tags
                    config:
                      type: select
                      renderType: selectMultipleSideBySide
                      items:
                        - [ 'Tag A', '1' ]
                        - [ 'Tag B', '2' ]
                        - [ 'Tag C', '3' ]
                                
              formEditor:
                iconIdentifier: 't3-form-icon-finisher'
                label: 'A Label that seems to be never used...'
                predefinedDefaults:
                  options:
                    tags: ''

          formElementsDefinition:
            Form:
              formEditor:
                editors:
                  900:
                    # Make finisher available to be selected in the form editor
                    selectOptions:
                      80:
                        value: 'TagFinisher'
                        label: 'Tag Finisher'

                propertyCollections:
                  finishers:
                    # Define the fields of the finisher
                    30:
                      identifier: 'TagFinisher'
                      editors:
                        100:
                          identifier: header
                          templateName: Inspector-CollectionElementHeaderEditor
                          label: "Tag Finisher"

                        #
                        # This is the select field in the form editor that should be filled dynamically
                        #
                        200:
                          identifier: 'tags'
                          templateName: 'Inspector-MultiSelectEditor'
                          label: 'Tags'
                          propertyPath: 'options.tags'
                          selectOptions:
                            -
                              value: '1'
                              label: 'Tag A'
                            -
                              value: '2'
                              label: 'Tag B'
                            -
                              value: '3'
                              label: 'Tag C'
                        9999:
                          identifier: 'removeButton'
                          templateName: 'Inspector-RemoveElementEditor'

As you can see, I'll have to declare all select options twice. Once for the Form Editor and once for the Content Element with the Form Plugin. So the solution should be able to add the data to both (or am I doing something wrong?). But I would be happy to have a solution for one of those as well.

Configuration of form finisher in the content element's plugin tab

Any hints to a documentation or code snippet are welcome too.

Upvotes: 0

Views: 95

Answers (0)

Related Questions