Expected argument of type “string”, “NULL” given when using form in Symfony 4.1

Expected argument of type “string”, “NULL” given is very common question and seems to not be handled since Symfony 2

So if you are using forms and got such error after submit – digging to find what is causing can be very annoying. The easiest solution is to find file:
vendor/symfony/property-access/PropertyAccessor.php

and in function:
public function setValue(&$objectOrArray, $propertyPath, $value)

almost at end, just before:
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0);

just add:

This will cause to print all required data to find which field is causing issue. The most important is $propertyPath variable which will give you name of field:

At given example fieldname is “csvField”.

Leave a Reply