When I try to get the data from event PRE_SET_DATA, I get my object with good value, but I can't use it.
This is my test code :
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function(FormEvent $event) use ($factory){
$data = $event->getData();
print_r($data);
}
);
This returns a long text :
"YOU\CommercantBundle\Entity\LivraisonChoix Object ( [id:YOU\CommercantBundle\Entity\LivraisonChoix:private] => 22 ..."
But when I use a getter :
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function(FormEvent $event) use ($factory){
$data = $event->getData();
print_r($data->getId());
}
);
I get an error :
FatalErrorException: Error: Call to a member function getId() on a non-object
How can I access to data?
This work fine for PRE_BIND event.
I need to use this condition for the getter work :