#106883Property name being integer, throws exception in property mapping
Description
Sending a form data like this (with a integer named property, in this example “4”)
tx_bizzupevents_events[checkout][tickets][4][quantity]: "3"
throws
TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration::forProperty(): Argument #1 ($propertyPath) must be of type string, int given, called in /var/www/html/vendor/typo3/cms-extbase/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php on line 184Because of the 4 not being casted as a integer, and not casted into a string in the
MvcPropertyMappingConfigurationService::modifyPropertyMappingConfigurationmethod
foreach ($propertyConfiguration as $innerKey => $innerValue) {
if (is_array($innerValue)) {
$this->modifyPropertyMappingConfiguration($innerValue, $propertyMappingConfiguration->forProperty($innerKey)); #THIS LINE HERE, THE VARIABLE $innerKey
}
$propertyMappingConfiguration->allowProperties($innerKey);
}
the forProperty method had it’s argument type set to strictly string in this commit
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 5
-
Stefan Froemken commented <span data-processor="relativetime" data-value="2025-06-19T13:18:05+00:00" > 06/19/25, 13:18 </span>
Hi,
thanks for reporting this and for providing the example markup. I’d like to offer some clarification on the issue you’re facing with the property mapping in Extbase, specifically in the context of <f:form></f:form> and ObjectStorage .
The core of the problem is that you’re using the tickets UID as a key in the input field’s name attribute, e.g.:
<f:form.textfield property="tickets.{ticket.uid}.quantity" ... />However, ObjectStorage , which Extbase uses internally to manage collections of objects, does not use UIDs or numeric indexes as keys. Instead, it uses spl_object_hash values to internally map and identify objects. This means that when Extbase tries to map form data back onto the domain model, it cannot resolve
tickets[4]
to a valid object reference within the ObjectStorage , because the key 4 has no meaning in that context.
This is what causes the exception you’re seeing:
PropertyMappingConfiguration::forProperty(): Argument #1 ($propertyPath) must be of type string, int givenIt is a symptom of how the nested array structure is interpreted.
tickets[4][quantity]
tries to map the integer 4 as a property path segment, which is invalid in this context.
Recommended Solution
To make the form mapping compatible with Extbase, you should ensure that the form fields are indexed in a way Extbase understands. A reliable approach is to convert the ObjectStorage to a plain array using:
$this->tickets->toArray()in your getter (e.g., getTickets()), which gives you an array with integer keys (0, 1, etc.). This ensures predictable indexing and allows your template to refer to fields like:
<f:for each="{event.tickets}" as="ticket" iteration="iterator"> <f:form.textfield property="tickets.{iterator.index}.quantity" ... /> </f:for>Or, alternatively:
public function getTickets(): array { return $this->tickets->toArray(); }This allows Extbase to treat the collection as a plain array during form rendering and submission, and the indices
_tickets[0]_, _tickets[1]_, ...
will be consistent between form output and input processing.
I’ve successfully used this approach in one of my public extensions ([clubdirectory](https://github.com/jweiland-net/clubdirectory/blob/8.0.0/Resources/Private/Partials/Club/FormFields.html#L80)), where the same concept was applied to handle nested form data for object collections.
It is important to note that Extbase identifies related domain objects (e.g. items in an ObjectStorage) not by their position in the property path, but by using hidden input fields that carry the object’s unique identifier. These fields are named “__identifier”, and Extbase uses them internally during the property mapping process to correctly rehydrate objects from the submitted form data:
<input type="hidden" name="tx_myext_domainmodel[relatedObjects][0][__identifier]" value="123" />This mechanism ensures that the correct persisted entity is referenced, regardless of its array position or UID in the visible form fields.
Stefan
-
Garvin Hicking changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-06-19T16:15:26+00:00" > 06/19/25, 16:15 </span> -
Soren Malling commented <span data-processor="relativetime" data-value="2025-07-03T16:37:13+00:00" > 07/03/25, 16:37 </span>
That makes sense 👌
-
Garvin Hicking commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2025-07-03T16:40:22+00:00" > 07/03/25, 16:40 </span>Close as making sense ;)
Form creating the submitted form and data
<f:form controller="Checkout" action="create" name="checkout"> <f:form.hidden property="event" value="{event}" /> <section class="event-tickets" aria-labelledby="tickets-heading"> <h2 id="tickets-heading">Available Tickets</h2> <ul class="ticket-list"> <f:for each="{event.tickets}" as="ticket"> <li> <strong>{ticket.name}</strong> {ticket.pricing.amount -> f:format.currency(decimals: 2, decimalSeparator: ',', thousandsSeparator: '.', currencySign: settings.tickets.currency)} <f:form.textfield property="tickets.{ticket.uid}.quantity" value="0" type="number" min="0" step="1" /> </li> </f:for> </ul> </section> <button type="submit">Køb</button> </f:form>