Overwrite YAML-Files of individual forms with typoscript - typo3

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

Related

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

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.

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

Fill PDF form using perl or node

I need to fill PDF form, Which contains radio buttons too. I tried to fill it with perl, CAM::PDF module and with node, pdf-fill-form module.
In node, the radio's value is always undefined:
{
name: 'Op1',
page: 14,
value: undefined,
id: 983128,
type: 'radio'
}
In perl, the object's value looks like this (if the first option is checked is S, second: XL, third: 2XL etc):
'V'=> bless({
'gennum'=>0,
'value'=>'S',
'type'=>'label',
'objnum'=>988
},
'CAM: : PDF: : Node')
If I change the S to XL, nothing happens in the PDF.
Has somebody any idea, How to fill the radio box?
You can do with node js npm pdf-fill-form module.
let say you are trying to set gender:
your radio button must be formed this way.
{ name: 'gender',
page: 0,
value: false,
id: 65558,
caption: 'male',
type: 'radio' },
{ name: 'gender',
page: 0,
value: false,
id: 65559,
caption: 'female',
type: 'radio' }
Here caption is the important one.
if you trying to set gender is male means just do this
{ gender: 'male'}

How to add number validation in Neos form?

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: ''

Display sonata mongodb admin bundle

i'm adding Sonata mongoDB admin Bundle in my project, after doing all the config, it seems that the bundle works fine but there is a problem it does not display the list of the document which is supposed to display.
when i go to /admin i find the sonata admin template but i got it empty. here is my config.yml :
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata_doctrine_mongo_db_admin:
templates:
form:
- SonataDoctrineMongoDBAdminBundle:Form:form_admin_fields.html.twig
filter:
- SonataDoctrineMongoDBAdminBundle:Form:filter_admin_fields.html.twig
types:
list:
array: SonataAdminBundle:CRUD:list_array.html.twig
boolean: SonataAdminBundle:CRUD:list_boolean.html.twig
date: SonataAdminBundle:CRUD:list_date.html.twig
time: SonataAdminBundle:CRUD:list_time.html.twig
datetime: SonataAdminBundle:CRUD:list_datetime.html.twig
text: SonataAdminBundle:CRUD:base_list_field.html.twig
trans: SonataAdminBundle:CRUD:list_trans.html.twig
string: SonataAdminBundle:CRUD:base_list_field.html.twig
smallint: SonataAdminBundle:CRUD:base_list_field.html.twig
bigint: SonataAdminBundle:CRUD:base_list_field.html.twig
integer: SonataAdminBundle:CRUD:base_list_field.html.twig
decimal: SonataAdminBundle:CRUD:base_list_field.html.twig
identifier: SonataAdminBundle:CRUD:base_list_field.html.twig
show:
array: SonataAdminBundle:CRUD:show_array.html.twig
boolean: SonataAdminBundle:CRUD:show_boolean.html.twig
date: SonataAdminBundle:CRUD:show_date.html.twig
time: SonataAdminBundle:CRUD:show_time.html.twig
datetime: SonataAdminBundle:CRUD:show_datetime.html.twig
text: SonataAdminBundle:CRUD:base_show_field.html.twig
trans: SonataAdminBundle:CRUD:show_trans.html.twig
string: SonataAdminBundle:CRUD:base_show_field.html.twig
smallint: SonataAdminBundle:CRUD:base_show_field.html.twig
bigint: SonataAdminBundle:CRUD:base_show_field.html.twig
integer: SonataAdminBundle:CRUD:base_show_field.html.twig
decimal: SonataAdminBundle:CRUD:base_show_field.html.twig
and here is my admin.yml (i followed the documentation) :
services:
sonata.admin.question:
class: ATS\AdminBundle\Admin\questionAdmin
tags:
- { name: sonata.admin, manager_type: doctrine_mongodb, group: "Content", label: "Question" }
arguments:
- ~
- ATS\QuizzBundle\Document\Question
- ~
calls:
- [ setTranslationDomain, [ATSAdminBundle]]
and finally here is my questionAdmin class (until here i need only to show the list of my questions stored in the db) :
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Show\ShowMapper;
class questionAdmin extends Admin
{
// Fields to be shown on create/edit forms
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('question')
->add('weight')
// ->add('tags')
// ->add('commentsEnabled')
//add custom action links
->add('_action', 'actions', array(
'actions' => array(
'view' => array(),
'edit' => array(),
)
))
;
}
Any one have the solution plz ? thank you