1
votes

i tried for a few hours to overwrite some parameters in a yaml file of a form with typoscript. I found this passage in the manual:

https://docs.typo3.org/c/typo3/cms-form/9.5/en-us/Concepts/FrontendRendering/Index.html?highlight=formdefinitionoverrides#typoscript-overrides

But i could not get it to work. Additional i could not find a way to debug my yaml definitions. I tried the hint with

 typo3/sysext/form/Classes/Mvc/Configuration/ConfigurationManager.php::getConfigurationFromYamlFile()

but this shows only the prototypes not the forms.

So i do have some questions:

  • is there a possibility to debug the combined code of yaml and typoscript for a form?
  • does formDefinitionOverrides as described in the manual really work (TYPO3 9.5)
  • what is ? The identifier of my form in the yaml file or the identifier in the frontend with the number of the content element (myFormIdentifier-UidOfMyContentElement)
  • is it possible to work with identifiers instead of array indizes? (multiple nested array indizes with up to 10 or more entries driving me crazy.

Thanks!

2

2 Answers

1
votes

I found how to use labels instead of using numbered arrays:

the yaml:

type: Form
identifier: test1
prototypeName: standard
renderables:
  page1:
    renderingOptions:
      previousButtonLabel: 'Previous step'
      nextButtonLabel: 'Next step'
    type: Page
    identifier: page-1
    label: Step
    renderables:
      field1:
        defaultValue: ''
        type: Text
        identifier: email-1
        label: 'My Email address'
        properties:
          validationErrorMessages:
            -
              code: 1221559976
              message: öasdlkhfö

and the typoscript:

plugin.tx_form{
    settings{        
        formDefinitionOverrides {
            # identifier of form
            test1 {
                renderables {
                    # first page of form
                    page1 {
                        renderables {
                            field1 {
                                label = TEXT
                                label.value = Eine ganze andere E-Mailaddresse
                            }
                        }
                    }
                }
            }
        }
    }
}

works nice, but you cannot mix it - all fileds in one level has to get labels. That makes sense because it is not possible to mix indices and keys in a php array.

0
votes

Yes, it does work. Here's an example.

The identifier in this example is "myformEN".

With TypoScript you can't do it without this nested array syntax.

TypoScript

plugin.tx_form{
    settings{
        yamlConfigurations.100 = EXT:user_site/Configuration/Form/CustomFormSetup.yaml
        
        formDefinitionOverrides {
            # identifier of form
            myformEN {
                renderables {
                    # first page of form
                    0 {
                        renderables {
                            # number of element in form
                            0 {
                                # another level (because of "Grid: Row")
                                renderables {
                                    0 {
                                        defaultValue = TEXT
                                        defaultValue.value = My Text
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

myformEN.form.yaml

renderingOptions:
    submitButtonLabel: 'submit'
identifier: myformEN
label: 'Inquiry'
type: Form
prototypeName: standard
[…]
renderables:
  -
    renderingOptions:
      previousButtonLabel: ''
      nextButtonLabel: Next
    identifier: page-1
    label: ''
    type: Page
    renderables:
      -
        type: GridRow
        identifier: gridrow-1
        label: 'Grid: Row'
        renderables:
          -
            defaultValue: 'this will be overwritten by TypoScript'
            type: Text
            identifier: article
            label: Article
          -
            defaultValue: ''
            type: Text
            identifier: text-2
            label: 'Amount'
[…]