we have a problem with the sonata admin export feature. we
have a basic entity, Home, and a one-to-many related entity Currency
storing the currency in which the prices will be held:
Front\PropertyBundle\Entity\Currency", cascade={"persist"})
* @ORM\JoinColumn(name="currency_id", referencedColumnName="id", unique=false)
*/
protected $currency;
Currency.php:
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string $name
*
* @ORM\Column(name="name", type="string", length=30, nullable=true)
*/
protected $name;
this field is not mandatory while inserting a new home, so many homes in the table have the currency_id column set to null
when selecting fields to export:
HomeAdmin.php:
public function getExportFields()
{
return array(
'
currency.name',
...
);
}
the export fails when homes without currency appear in the list, we get this exception:
Expected argument of type "object or array", "NULL" given
in /var/www/sites/
dev.rentamosya.com.mx/vendor/symfony/src/Symfony/Component/Form/Util/PropertyPath.php at line 202
watching inside the code, we see the features uses the DoctrineORMQuerySourceIterator.php, which for everyfield expects an array or an object, and in our case null is given since the field not filled
thanks a lot in advance for your help