kitzberger / form-mailtext

TYPO3 extension to enhance EXT:form by custom mail texts per form plugin
7 stars 5 forks source link

Conflict with form_element_linked_checkbox extension #19

Open markustobler opened 2 years ago

markustobler commented 2 years ago

The extension does not work in combination with ext form_element_linked_checkbox. Is there a known workaround for this problem?

kitzberger commented 2 years ago

@markustobler, don't know that extension, sorry :-/ Maybe you can describe the problem you're experiencing a little?

klodeckl commented 2 years ago

I can confirm this. I used both extensions, worked with TYPO3 9 perfectly (but I also overrided the templates, I don’t know if it worked without). I recently updated (my dev system) TYPO3 to 10 an all extensions and then ran into this issue.

The problem is that form_element_linked_checkbox has the following yaml config:

          finishersDefinition:
            EmailToReceiver:
              options:
                templateRootPaths:
                  1505042806: 'EXT:form_element_linked_checkbox/Resources/Private/Frontend/Templates/Finishers/Email/'
            EmailToSender:
              options:
                templateRootPaths:
                  1505042806: 'EXT:form_element_linked_checkbox/Resources/Private/Frontend/Templates/Finishers/Email/'

So it overrided the templates of form_mailtext using higher template numbers in my own yaml config and a custom template:

         finishersDefinition:
            EmailToReceiver:
              options:
                templateRootPaths:
                  1505042806: 'EXT:form_element_linked_checkbox/Resources/Private/Frontend/Templates/Finishers/Email/'
            EmailToSender:
              options:
                templateRootPaths:
                  2505042806: 'EXT:form_element_linked_checkbox/Resources/Private/Frontend/Templates/Finishers/Email/'

So either form_mailtext should use a higher number (and include the part of the form_element_linked_checkbox template) or the template in form_element_linked_checkbox should be adopted for form_mailtext. I would prefer the first option. Best solution would be if form_mailtext would be integrated into the form extension.

Sorry, I still don’t understand how to post code here in github…

patrickmsieber commented 2 years ago

Had the same issue, @klodeckl solution worked fine for me.

form_mailtext should use a higher number (and include the part of the form_element_linked_checkbox template)

kitzberger commented 2 years ago

@klodeckl,

Sorry, I still don’t understand how to post code here in github…

A code block can be wrapped into "triple-ticks" (```) to be rendered as code.

kitzberger commented 2 years ago

@klodeckl, just to be sure I understand it correctly: the problem is the indicies of those to lines?

https://github.com/tritum/form_element_linked_checkbox/blob/master/Configuration/Yaml/FormSetup.yaml#L72

1505042806: 'EXT:form_element_linked_checkbox/Resources/Private/Frontend/Templates/Finishers/Email/'

https://github.com/kitzberger/form-mailtext/blob/main/Configuration/Form/MailtextFormSetup.yaml#L10

20: 'EXT:form_mailtext/Resources/Private/Frontend/Templates/Finishers/Email/'

Shouldn't that number of EXT:form_element_linked_checkbox already be high enough to be overriding the template of my extension? Why would increasing that number by another 1000000000 change anything?

kitzberger commented 2 years ago

And I still don't know what the actual problem is. An exception? The field not being rendered at all, the field not being rendered in the sent mails...

I've just installed that extension and it seemed fine to me.

patrickmsieber commented 2 years ago

The problem was that when EXT:form_element_linked_checkbox is installed, EXT:form_element_linked_checkbox is overriding EXT:form_mailtext with the result the custom message doesn't have an effect at all. Just the normal form field is being send via email (like {variables} would do).

Solution: In tx_form.typoscript (my_own_ext) set a higher number than EXT:form_element_linked_checkbox

plugin.tx_form {
    settings {
        yamlConfigurations {
            1505042816 = EXT:form_mailtext/Configuration/Form/MailtextFormSetup.yaml
        }
    }
}

module.tx_form {
    settings {
        yamlConfigurations {
            1505042816 = EXT:form_mailtext/Configuration/Form/MailtextFormSetup.yaml
        }
    }
}

In EXT:form_mailtext/Configuration/Form/MailtextFormSetup.yaml I set a higher number of the templateRootPaths:

          finishersDefinition:
            EmailToSender:
              options:
                templateRootPaths:
                  1505042806: 'EXT:form_element_linked_checkbox/Resources/Private/Frontend/Templates/Finishers/Email/' 
                  1505042816: 'EXT:form_mailtext/Resources/Private/Frontend/Templates/Finishers/Email/'
              # Extra field 'message' in finisher config in form plugin
              FormEngine:
                elements:
                  message:
                    label: 'formEditor.elements.Form.finisher.EmailToSender.editor.message.label'
                    config:
                      type: text
                      enableRichtext: true
                      eval: required
              formEditor:
                predefinedDefaults:
                  options:
                    message: "Hi, here's your input: {variables}"
            EmailToReceiver:
              options:
                templateRootPaths:
                  2505042806: 'EXT:form_element_linked_checkbox/Resources/Private/Frontend/Templates/Finishers/Email/'
                  2505042816: 'EXT:form_mailtext/Resources/Private/Frontend/Templates/Finishers/Email/'

(I don't really know if it's necessary to put the EXT:form_element_linked_checkbox number in EXT:form_mailtext but it worked)

Conclusion: I think it's not a bug but increasing the number(s) of the configuration and templateRootPaths could already help.

TYPO3: 11.5.12 PHP: 8.1.1 form_mailtext: 2.1.3

klodeckl commented 2 years ago

Exactly. EXT:form_element_linked_checkbox uses its own email template. By using a higher number the template of fom_mailtext comes into play, otherwise the template of form_element_linked_checkbox).

kitzberger commented 2 years ago

I don't wanna offend anyone but I'm having my doubts that changing the indicies in either of the two extensions is the right way to go here. I rather think that an integrator should always understand what an extension is doing and in case of a conflict like this find an appropriate solution for that given scenario.

In this example here a clean solution IMHO could look like this: create a custom email template that is the hybrid of both email templates: the one of EXT:form_mailtext and the one of EXT:form_element_linked_checkbox. As I see it the latter does only add this change:

{formvh:translateElementProperty(element: formValue.element, property: 'label') -> f:format.stripTags(allowedTags: '<a>')}

Allowing links withing form element labels. Right?

So I'd copy the template from EXT:form_mailtext to the "integrator" extension and add this little change manually. Then I'd use a combination of TypoScript and Yaml to give that file the highest indice so it's being used instead of the other two's.

Any other opinions?

kpnielsen commented 1 year ago

I agree with @kitzberger . The clean solution is to let the integrator fix this. Given that this conflict is known, though, I suggest adding a short paragraph in the README of this extension (and probably that of form_element_linked_checkbox, too), to maybe save integrators some time.