TYPO3-Headless / headless_powermail

Connects together EXT:headless and EXT:powermail
GNU General Public License v2.0
0 stars 6 forks source link

PHP Warning: Undefined array key -1 in PrefillMultiFieldViewHelper #29

Closed kitzberger closed 1 year ago

kitzberger commented 1 year ago

PHP Warning: Undefined array key -1 in EXT:powermail/Classes/ViewHelpers/Misc/PrefillMultiFieldViewHelper.php line 209

When having a server side validation error and rendering the form for the 2nd time with prefilled values for radio, checkbox and select fields, that warning occurs. It's probably due to the fact, that index.cycle isn't existing at all and thus cycle is 0 within that viewhelper which reduces that value by 1 which makes it that weird -1!

    <headlesspowermail:form.registerField property="{field.marker}"
                            value="{setting.value}"
                            checked="{vh:misc.prefillMultiField(field:field, mail:mail, cycle:index.cycle)}"/>

This is an excerpt from the partials Radio.html, Check.html and Select.html

kitzberger commented 1 year ago

@lukaszuznanski, I stumbled upon this issue again and tried to make sense of what's the real problem here.

Maybe you can help me understand this excerpt from the check/radio/select/country field partials:

    <headlesspowermail:form.registerField property="{field.marker}."
                            value="{setting.value}"
                            checked="{vh:misc.prefillMultiField(field:field, mail:mail, cycle:index.cycle)}"/>

It's used to create the trustedProperties, right? E.g.

{
  "name": "tx_powermail_pi1[__trustedProperties]",
  "value": "{\"field\":{\"anrede\":1,\"vorname\":1,\"nachname\":1,\"strasse\":1,\"hausnummer\":1,\"plz\":1,\"ort\":1,\"land\":1,\"country\":1,\"email\":1,\"newsletter\":[1]}}34a29410e84c1f4afb07b7d002fda0503bde9b3f"
},

Why does headlesspowermail:form.registerField have to have the parameters value and checked though? In my opinion that's not necessary at all.

And checked is using the prefillMultiField viewhelper with a wrong cycle parameter, what's the intention behind that?