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:
echo '<pre>'; \Doctrine\Common\Util\Debug::dump($propertyPath); \Doctrine\Common\Util\Debug::dump($value); Doctrine\Common\Util\Debug::dump($objectOrArray); echo '</pre>'; exit;
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:
object(stdClass)#4165 (5) { ["__CLASS__"]=> string(45) "Symfony\Component\PropertyAccess\PropertyPath" ["elements:Symfony\Component\PropertyAccess\PropertyPath:private"]=> array(1) { [0]=> string(8) "csvField" } ["length:Symfony\Component\PropertyAccess\PropertyPath:private"]=> int(1) ["isIndex:Symfony\Component\PropertyAccess\PropertyPath:private"]=> array(1) { [0]=> bool(false) } ["pathAsString:Symfony\Component\PropertyAccess\PropertyPath:private"]=> string(8) "csvField" }
At given example fieldname is “csvField”.