How to add number validation in Neos form? - neoscms

I have to validate a textbox in Neos form. I want to validate a number between 7 to 90.
Here is my code, but it is not working:
type: 'TYPO3.Form:SingleLineText'
identifier: liednummer
label: 'Die Nummer meines Lieblingsliedes'
validators:
- identifier: 'TYPO3.Flow:NotEmpty'
- identifier: 'TYPO3.Flow:NumberRange'
properties:
placeholder: 'Liednummer'
validation:
'TYPO3\Flow\Validation\Validator\NumberRangeValidator':
minimum: 7
maximum: 90
defaultValue: ''
What is wrong? Empty is working, but number and number range is not working.

Quite old question, so you have probably solved that problem, but maybe it will help someone else:
type: 'TYPO3.Form:SingleLineText'
identifier: liednummer
label: 'Die Nummer meines Lieblingsliedes'
validators:
-
identifier: 'TYPO3.Flow:NumberRange'
options:
minimum: '8'
maximum: '22'
-
identifier: 'TYPO3.Flow:NotEmpty'
properties:
placeholder: 10
defaultValue: ''

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"]'

TYPO3 tx_form doesn't render submit button

I have a 10.4.18 installation, on another project that works fine (which i copy to the current). In my current project they render the submit button like this:
<span class="btn-group next submit">
Absenden
</span>
There is no button and not clickable, anyone have an idea? There are no template overrides or custom configuration, form is added in template (without I get an exception) so that works.
The yaml configuration:
renderingOptions:
submitButtonLabel: Absenden
identifier: kontakt
label: Kontakt
type: Form
prototypeName: standard
finishers:
-
options:
subject: 'Kontakt über Website'
recipients:
test#test.de: 'Test Webmailer'
senderAddress: '{email}'
senderName: '{vorname}'
attachUploads: true
translation:
language: default
useFluidEmail: true
title: 'Confirmation of your message'
addHtmlPart: true
identifier: EmailToReceiver
renderables:
-
renderingOptions:
previousButtonLabel: ''
nextButtonLabel: ''
identifier: page-1
label: Kontakt
type: Page
renderables:
-
properties:
options:
Anfrage: Anfrage
Lob: Lob
Kritik: Kritik
type: SingleSelect
identifier: singleselect-1
label: 'Ihr Anliegen'
defaultValue: Anfrage
-
defaultValue: ''
identifier: vorname
label: 'Ihr Name'
type: Text
properties:
fluidAdditionalAttributes: { }
elementDescription: ''
-
defaultValue: ''
identifier: email
label: 'Ihre E-Mail-Adresse'
type: Text
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
-
identifier: EmailAddress
-
defaultValue: ''
identifier: nachricht
label: 'Ihre Nachricht'
type: Textarea
properties:
fluidAdditionalAttributes:
required: required
elementDescription: ''
validators:
-
identifier: NotEmpty
-
properties:
pageUid: '13'
linkText: 'Datenschutzerklärung anzeigen'
fluidAdditionalAttributes:
required: required
type: LinkedCheckbox
identifier: linkedcheckbox-1
label: 'Ja, ich habe die Datenschutzerklärung zur Kenntnis genommen.'
validators:
-
identifier: NotEmpty

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 8.7.17 EXT:form - Add select to custom finisher with DB registers

I followed the gist written by Xavier Perseguers in order to add a custom finisher available for forms I create with EXT:form in TYPO3 v8.
I have made some modifications to add a select.
# EXT:my_ext/Configuration/Yaml/CreateRequestActionFrontend.yaml
TYPO3:
CMS:
Form:
prototypes:
# add our finisher to the 'standard' form prototype
standard:
formElementsDefinition:
Form:
formEditor:
editors:
# 900 = 'finishers' in EXT:form/Configuration/Yaml/FormEditorSetup.yaml
900:
selectOptions:
500:
value: 'CreateRequestAction'
label: 'Create request'
propertyCollections:
finishers:
500:
__inheritances:
10:'TYPO3.CMS.Form.mixins.FormEngineCreateRequestActionMixin'
identifier: 'CreateRequestAction'
editors:
__inheritances:
10: 'TYPO3.CMS.Form.mixins.formElementMixins.BaseCollectionEditorsMixin'
100:
label: 'Create request'
200:
identifier: 'requestType'
templateName: 'Inspector-SingleSelectEditor'
label: 'Request type'
propertyPath: 'options.requestType'
selectOptions:
10:
value: '1'
label: 'OPTION 1'
20:
value: '2'
label: 'OPTION 2'
30:
value: '3'
label: 'OPTION 3'
finishersDefinition:
CreateRequestAction:
formEditor:
iconIdentifier: 't3-form-icon-finisher'
predefinedDefaults:
options:
requestType: '1'
mixins:
FormEngineCreateRequestActionMixin:
elements:
requestType:
config:
type: 'select'
On the other hand, I have domain objects stored in my database; I want those objects to be select options. My question is: How can I do that?
Thank you so much.

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>