I am working on a Symfony 2.7 application that uses the Sonata admin bundle. I have a form defining a Video that allows users to select a Country of origin from a dropdown. Each user entity already has a Country of origin associated with it, so I merely want to give their country as a default value, with the option of selecting others. Here is the code as I have it now:
$formMapper
...
->add('countryOfOrigin',
'country_of_origin',
[ 'data' => $user->getOriginCountry() ])
The problem is that this code as it currently exists overwrites any previous selection -- making a user who is from Denmark always have 'Denmark' selected on form reload, even if they had previously told the application to associate the Video with 'Italy.'
How can I create a default dropdown value without overwriting what the user selects?