0
votes

I have an extension and a frontend form to create and update elements. The user can create an invoice with several dates which are stored as m:n records.

Creating an invoice and dates works with:

<f:form.checkbox name="newRechnungen[termine][]" value="{termin.uid}" />

But if I edit invoice and submit form, I get errors:

<f:form.checkbox name="rechnungen[termine][]" value="{termin.uid}" />

shows errror like:

The form field "[items][][]" is invalid. Reason: "[]" used not as last argument, but somewhere in the middle (like foo[][bar])

changing the tag like described for solution to

<f:form.checkbox name="rechnungen[termine][{key}]" value="{termin.uid}" />

shows error:

#1297759968: Exception while property mapping at property path "files": PHP Warning: spl_object_hash() expects parameter 1 to be object, null given in /usr/share/typo3/typo3_src-7.6.2/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php line 155 =

The solution described on the documentation page with enctype="multipart/form-data" for form tag is not working.

Any idea how I can solve this?

2

2 Answers

0
votes

I could solve it now by unset the empty values in initializeUpdateAction:

foreach($args['rechnungen']['termine'] as $key => $value) {
        if (intval($value) === 0) {
            unset($args['rechnungen']['termine'][$key]);
        }
    }
0
votes

Check if the generated HTML for the checkbox below has the correct format.

<f:form.checkbox name="rechnungen[termine][{key}]" value="{termin.uid}" />

You must have something like this in your HTML: <input type="checkbox" name="tx_yourext_plugin[rechnungen][termine][1] value="__your value__" />

The name like this tx_yourext_plugin[rechnungen][termine][] will not work.

By the error above I can say that your {key} variable is null. Try a <f:debug>{key}</f:debug> to check if it's null or not.

UPDATE

Add in your setter parameter setTermine(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $temines = null)