A Form listener + transformer binding Also, for instance, can see Sonata SecurityRolesType.class
$formMapper
->get('realRoles')
->addModelTransformer(new StringToArrayTransformer());
->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) {
$form = $event->getForm();
$data = $event->getData();
$qw = 2;
$result = array();
if ($data) {
foreach ($data as $key => $value) {
$result[] = array(
'key' => $key,
'value' => $value
);
}
}
$event->setData($result);
}, 1);