Ciao a tutti!
La lista sta diventando silenziosa....immagino ormai si usi principalmente stackoverflow...
Ci provo lo stesso!
Allora: sto usando dei form per filtrare dei dati. Uno dei campi del form è un EntityType.
Qualcosa del tipo:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('utente', EntityType::class, array(
'required' => false,
'class' =>'Epod4\AppBundle\Entity\Utente'
));
}
Quando effettuo la ricerca, mi salvo i parametri del form inviato in questo modo:
$request->getSession()->set('filtro.eventi_log.ricerca', $filtro->getData());
In questo modo, se nel controller arrivo tramite una get, mi ricarico l'ultima ricerca:
$filtro->setData($request->getSession()->get('filtro.eventi_log.ricerca'));
Facendo così, però, ho il seguente errore:
Entity of type "Epod4\AppBundle\Entity\Utente" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?
Il problema sembra scatenarsi dal fatto che l'oggetto salvato in sessione non è più 'legato' all'ORM. quindi
vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php
Esegue $values[$i] = (string) $this->idReader->getIdValue($object);
che restituisce l'errore di cui sopra.
Esiste una scorciatoia o devo ritoccare a mano il transformer oppure gestire la serializzazione dell'oggetto quando lo salvo in sessione ?
Oppure c'è qualcosa che mi sfugge ?
Grazie a tutti per l'attenzione
Luca
--
It is easier to move a problem around (for example, by moving the problem to a different part of the overall network architecture) than it is to solve it.
6th truth - rfc1925
------------------------------------------------------------------
Einstein: Imagination is more important than knowledge. For knowledge is limited, whereas imagination embraces the entire world, stimulating progress, giving birth to evolution.
------------------------------------------------------------------
Heinlein: Specialization is for Insects