powermail icon indicating copy to clipboard operation
powermail copied to clipboard

Exception Undefined array key "pi_flexform" when including powermail form via TypoScript (fix provided)

Open tntrpsw opened this issue 1 year ago • 1 comments

Using TypoScript to include a powermail form seems to work, but when sending the form, there is an exception:

PHP Warning: Undefined array key "pi_flexform" in /var/www/web-dev8/html/typo3conf/ext/powermail/Classes/Domain/Validator/AbstractValidator.php line 136

Tested using powermail 12.3.1 under TYPO3 12.4.14, the problem seems to be, that within the constructor of the class "AbstractValidator" the key "pi_flexform" of the "data" array is assumed to be existing. This however is not the case when using TypoScript to include the form - there is no content object.

Quickly changing the following lines ...

$this->flexForm = $flexFormService->convertFlexFormContentToArray(
            // @extensionScannerIgnoreLine Seems to be a false positive: getContentObject() is still correct in 9.0
            $configurationManager->getContentObject()->data['pi_flexform']
);

... to this ...

$this->flexForm = $flexFormService->convertFlexFormContentToArray(
            // @extensionScannerIgnoreLine Seems to be a false positive: getContentObject() is still correct in 9.0
            $configurationManager->getContentObject()->data['pi_flexform'] ?? ''
);

... fixes the bug.

By the way: is there an official way to include a powermail form via TypoScript? Is using the following the way to go?

321 = USER_INT
321 {

    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = Powermail
    pluginName = Pi1
    vendorName = In2code
    controller = Form
    action = form

    settings {

      flexform {
        main.form = 123

        receiver.name = name of the receiver
        receiver.email = [email protected]

        receiver.subject = subject of the email
        receiver.body = {powermail_all}
	  }

    }

}

tntrpsw avatar May 07 '24 15:05 tntrpsw

Thx.

Your "fix" will be included in the next release.

But be aware

This is not an officially supported way to use EXT:powermail. Problably there are other extensions, that fit better into this usecase /f.e. EXT:form)

All necessary flexform values must be set in the TypoScript as mentioned here. We will not take care of any further warnings and exceptions, if you decide to include Powermail via TypoScript.

mschwemer avatar May 21 '24 11:05 mschwemer

Included in 12.3.4

mschwemer avatar Jun 03 '24 09:06 mschwemer