简体   繁体   English

如何使用TypoScript覆盖TYPO3表单框架的YAML设置?

[英]How can I override YAML settings of the TYPO3 Form Framework with TypoScript?

I've created a TYPO3 form via the form framework. 我已经通过表单框架创建了TYPO3表单。 Now I want to override some of these values with TypoScript. 现在,我想用TypoScript覆盖其中一些值。 The form is stored in an extension, which can be used for every customer. 表单存储在扩展程序中,该扩展程序可用于每个客户。 The customer specific values should be overridden by my template extension which includes only customer specific settings. 客户特定的值应被我的模板扩展覆盖,该模板扩展仅包含客户特定的设置。 But the form framework doesn't use these settings. 但是表单框架不使用这些设置。 The TypoScript is loaded (Template Analyzer) and I cleared all caches. TypoScript已加载(模板分析器),并且我清除了所有缓存。

I currently use TYPO3 Version 9.5.6 and the form framework has the same version. 我当前使用TYPO3版本9.5.6,并且表单框架具有相同的版本。

This is a snippet from the form: 这是以下形式的代码段:

identifier: bewerbungsformular
label: Bewerbungsformular
type: Form
prototypeName: bewerbungen
finishers:
  -
    options:
      subject: 'Ihre Bewerbung'
      recipientAddress: '{text-email}'
      recipientName: 
      senderAddress: 
      senderName: Test Company 
      replyToAddress: ''
      carbonCopyAddress: ''
      blindCarbonCopyAddress: ''
      format: html
      attachUploads: false
    identifier: EmailToSender

And this is my setup.ts in my template extension. 这是模板扩展中的setup.ts。 I found this snippet in the TYPO3 documentation. 我在TYPO3文档中找到了这个片段。 But there was no further explanation how the path to the value should look. 但是,没有进一步的解释说明该值的路径应该如何。 I think something in the path is wrong: 我认为路径中有错误:

plugin.tx_form {
    settings {
        yamlSettingsOverrides {

            #I think here is the mistake
            bewerbungsformular.finishers.EmailToSender.options.senderName = XYZ Company
        }
    }
}

Thanks. 谢谢。

For TypoScript overrides you need to use exactly the keys used in your form definition. 对于TypoScript覆盖,您需要完全使用表单定义中使用的键。 Notice that lists are basically the same as hashes with numeric keys after conversion to an PHP array. 请注意,转换为PHP数组后,列表基本上与带有数字键的哈希相同。

So in YAML this: 因此在YAML中:

- foo
- bar

Is the same as this: 与此相同:

0: foo
1: bar

Also you have used yamlSettingsOverrides which must be formDefinitionOverrides instead. 另外,您已经使用了yamlSettingsOverrides ,它必须改为formDefinitionOverrides

So your code should look like this instead: 因此,您的代码应如下所示:

plugin.tx_form {
    settings {
        formDefinitionOverrides {
            bewerbungsformular {
                finishers {
                    0 {
                        options {
                            senderName = XYZ Company
                        }
                    }
                }
            }
        }
    }
}

As you can see, numeric indices are not as speaking as named indices. 如您所见,数字索引并不像命名索引那样。 So if you don't plan to use the form editor in the backend to make further changes to your form definition you can directly use YAML hashes instead of lists: 因此,如果您不打算在后端使用表单编辑器来进一步更改表单定义,则可以直接使用YAML哈希代替列表:

identifier: bewerbungsformular
# ...
finishers:
  mailToSender:
    identifier: EmailToSender
    options:
      # ...

Then your TypoScript overrides could look like this: 然后,您的TypoScript替代可能如下所示:

plugin.tx_form {
    settings {
        formDefinitionOverrides {
            bewerbungsformular {
                finishers {
                    mailToSender {
                        options {
                            senderName = XYZ Company
                        }
                    }
                }
            }
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM