TYPO3: Form element.textarea-1.properties.defaultValue translation - forms

I'm working on translating a TYPO3 form.
All works like a charm, only the defaultValue attibute don't.
This is the relevant part of the form definition:
`
renderingOptions:
templateVariant: version2
submitButtonLabel: Abschicken
type: Form
identifier: productformular
label: 'Formular Produktseite'
prototypeName: standard
renderables:
-
renderingOptions:
previousButtonLabel: 'Previous step'
nextButtonLabel: 'Neue Seite'
type: Page
identifier: page-1
label: Produktanfrage
renderables:
-
defaultValue: 'Guten Tag, ich interessiere mich für dieses Gerät. Bitte melden Sie sich schnellstmöglich bei mir.'
type: Textarea
identifier: textarea-1
label: Nachricht
properties:
fluidAdditionalAttributes:
placeholder: 'Ihre Nachricht an uns'
`
Unfortunately, I can't find a hint in any instructions on how to translate the defaultValue.
Has anybody a soilution for me?
I tryed something like
`
<trans-unit id="productformular.element.textarea-1.properties.label">
<source>Message</source>
</trans-unit>
<trans-unit id="productformular.element.textarea-1.properties.placeholder">
<source>Your message to us</source>
</trans-unit>
<trans-unit id="productformular.element.textarea-1.properties.defaultValue">
<source>Hello, I am interested in this device. Please contact me as soon as possible.</source>
</trans-unit>
`
Label and placeholder are translated, but defaultValue doesn't.

I am not aware of a solution with XLIFF. But you can use Form variants to override the defaultValue:
-
defaultValue: 'Max Powers'
identifier: name
label: Name
type: Text
variants:
- identifier: defaultValue-for-de
condition: 'siteLanguage("twoLetterIsoCode") == "de"'
defaultValue: 'Max Mustermann'

As described in Rustyjim's post, TYPO3 does not (yet) provide this possibility.
I didn't want different forms per language, also a javascript solution didn't seem to fit for this.
I solved it now using the form view helper and the standard fluid translate function:
<formvh:render
persistenceIdentifier="EXT:liftfinder/Resources/Private/Forms/productContactForm.form.yaml"
overrideConfiguration="{
renderables: {
0: {
renderables: {
4: {
defaultValue: '{f:translate(key: \'textarea-1_defaultValue\')}'
}
}
}
}
}"
/>
It's not really a good solution either, because the elements are addressed by a sequence number instead of a unique identifier.
Better solutions are welcome.

Related

TYPO3 - cms-forms - Remove Input from Email

I am trying to remove an input field from the generated email. With Powermail it is relatively easy. There I can exclude fields in the typoscript. How could something like this look with cms-forms?
Example powermail
excludeFromPowermailAllMarker {
# On Confirmation Page (if activated)
confirmationPage {
# add some markernames (commaseparated) which should be excluded
excludeFromMarkerNames = datenschutzbestimmungen, agb
}
}
TYPO3 11.5.12
php 8.1.2
This is possible with the form variants introduced in TYPO3 version 9.
Hide a form element in certain finishers and on the summary step:
type: Form
identifier: test
prototypeName: standard
label: Test
finishers:
-
identifier: EmailToReceiver
options:
subject: Testmail
recipientAddress: tritum#example.org
recipientName: 'Test'
senderAddress: tritum#example.org
senderName: tritum#example.org
renderables:
-
type: Page
identifier: page-1
label: 'Page 1'
renderables:
-
type: Text
identifier: text-1
label: 'Text 1'
variants:
-
identifier: hide-1
renderingOptions:
enabled: false
condition: 'stepType == "SummaryPage" || finisherIdentifier in ["EmailToSender", "EmailToReceiver"]'
-
type: Text
identifier: text-2
label: 'Text 2'
-
type: SummaryPage
identifier: summarypage-1
label: 'Summary step'
The relevant part (which disables rendering of the field in the summary page, the email to sender finisher or the email to sender finisher) is
variants:
-
identifier: hide-1
renderingOptions:
enabled: false
condition: 'stepType == "SummaryPage" || finisherIdentifier in ["EmailToSender", "EmailToReceiver"]'

Overwrite YAML-Files of individual forms with typoscript

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!
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.
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'
[…]

TYPO3 Ext:form Checkbox Label with Link inside

I'm using the latest TYPO3 9.5.13 and made an contact form with the new form system extension: form
I need a checkbox before Submit button, f.e. "I've read the privacy policy .. "
I've found this extension, because this is not working out of the box.
https://github.com/tritum/form_element_linked_checkbox (installed via composer the latest master 1.1.0)
I can't create a Text like this: "Yes, I've read the privacy policy and blahablah .." The link is always at the end of the label. I've made it like they shown in the description of the extension form-element-linked-checkbox. Have I forget something? Here's my YAML
-
type: LinkedCheckbox
identifier: linkedcheckbox-1
label: ' Ja, ich habe die %s gelesen und bin mit der Verarbeitung meiner Daten einverstanden.'
properties:
pageUid: '17'
linkText: Datenschutzhinweise
elementDescription:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
my result in frontend:
I was blind!!! Damn!
Sorry, for my stupid error. I forgot the ' ' at labelText, see below:
-
type: LinkedCheckbox
identifier: linkedcheckbox-1
label: ' Ja, ich habe die %s gelesen und bin mit der Verarbeitung meiner Daten einverstanden.'
properties:
pageUid: '17'
linkText: 'Datenschutzhinweise'
elementDescription:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty

Translate custom validationErrorMessages in typo3 forms with locallang.xlf

I use locallang.xlf to translate my form (typo3 9.5.5, formextension).
my customform.yaml:
renderables:
-
properties:
fluidAdditionalAttributes:
required: required
validationErrorMessages:
-
code: 1221560910
message: 'My Custom Message'
code: 1221560718
message: 'My Custom Message'
-
code: 1347992400
message: 'My Custom Message'
-
code: 1347992400
message: 'My Custom Message'
options:
products: 'Products'
miscellaneous: 'Sonstiges'
prependOptionLabel: 'Please Specify'
type: SingleSelect
identifier: subject
label: 'Your Subject:'
validators:
-
identifier: NotEmpty
-
my locallang.xlf:
<trans-unit id="element.subject.properties.prependOptionLabel">
<source>Please Specify --Works!</source>
</trans-unit>
<trans-unit id="element.subject.properties.options.products">
    <source>Products --Works!</source>
</trans-unit>
<trans-unit id="element.subject.properties.validationErrorMessages.message">
<source>Custom Message -Doesn't work!</source>
</trans-unit>
With an exact translation key it works, except validationErrorMessages.
Does anyone know how to translate these?
You can use the following translation keys for validation error codes. 1221559976 is the code for the EmailAddress validator:
<trans-unit id="validation.error.1221559976">
<source>Please enter valid email address. Thanks!</source>
<target>Bitte gebe eine gültige E-Mail-Adresse ein. Danke!</target>
</trans-unit>
<trans-unit id="MyContactForm.validation.error.1221559976">
<source>Please enter valid email address. Thank you very much!</source>
<target>Bitte gebe eine gültige E-Mail-Adresse ein. Vielen herzlichen Dank!</target>
</trans-unit>
The latter will override the first, as it contains the form identifier and is therefore more specific.
Keep in mind that both of these translation keys will not work if you already set a custom message in your form definition!
This means, the last three lines of the following example have to be removed:
renderables:
-
defaultValue: ''
identifier: email
label: Email
type: Text
properties:
fluidAdditionalAttributes:
placeholder: 'Email address'
### Don't set this if you want to translate the message:
#validationErrorMessages:
# - code: 1221559976
# message: 'Please enter a valid email address, dear.'

TYPO3: Form properties.fluidAdditionalAttributes.placeholder translation

I'm working on translating my Typo3 page.
Now I've come to my contact form which I want to translate. From the Typo3 Documentation I've found that I need something like this:
contact.element.subject.properties.fluidAdditionalAttributes.placeholder
...as the translation ID inside my locallang.xlf file. I've linked my CustomFormSettings.yaml via TypoeScript, in there set the translation path to my extension and created a contact form.
I was actually able to translate the submit button for example and other buttons. But I can't get the placeholder inside my contact form to get translated, they all fallback to the value set in the contact form not the translation.
I'm guessing I'm handling the fluidAdditionalAttributes property wrong but I've tested lots of other combinations then the above.
What is the exact line I have to type inside my translation ID?
Here is my complete contact form:
renderingOptions:
submitButtonLabel: Submit
identifier: contact
label: Contact
type: Form
prototypeName: frameform
finishers:
-
options:
subject: 'Your message: {subject}'
recipientAddress: mail#mail.com
recipientName: 'Recipient Name'
senderAddress: '{email}'
senderName: '{name}'
replyToAddress: ''
carbonCopyAddress: ''
blindCarbonCopyAddress: ''
format: html
attachUploads: true
translation:
language: ''
identifier: EmailToReceiver
-
options:
subject: 'We have received: {subject}'
recipientAddress: '{email}'
recipientName: '{name}'
senderAddress: mail#mail.com
senderName: 'Sender Name'
replyToAddress: ''
carbonCopyAddress: ''
blindCarbonCopyAddress: ''
format: html
attachUploads: true
identifier: EmailToSender
-
options:
pageUid: '7'
additionalParameters: ''
identifier: Redirect
renderables:
-
renderingOptions:
previousButtonLabel: 'Previous step'
nextButtonLabel: 'Next step'
identifier: mainPage
type: Page
renderables:
-
defaultValue: ''
identifier: name
label: Name
type: Text
properties:
fluidAdditionalAttributes:
placeholder: Name
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
identifier: subject
label: Subject
type: Text
properties:
fluidAdditionalAttributes:
placeholder: Subject
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
identifier: email
label: Email
type: Text
properties:
fluidAdditionalAttributes:
placeholder: 'Email address'
required: required
validators:
-
identifier: NotEmpty
-
identifier: EmailAddress
-
defaultValue: ''
identifier: message
label: Message
type: Textarea
properties:
fluidAdditionalAttributes:
placeholder: Message
required: required
minlength: '10'
maxlength: '512'
validators:
-
identifier: NotEmpty
-
options:
minimum: '10'
maximum: '512'
identifier: StringLength
-
renderingOptions:
previousButtonLabel: 'Previous step'
nextButtonLabel: 'Next step'
identifier: summarypage
label: 'Summary page'
type: SummaryPage
You can override your placeholders in a locallang.xlf like this: element.<field-identifier>.properties.placeholder
example:
<trans-unit id="element.firstname.properties.placeholder">
<source>Your first name</source>
<target>Ihr Vorname</target>
</trans-unit>