You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm stuck on validating a registration form for a sporting event.
I have an Events table with a ManyToOne relationship on a TypeCompetitions table.
I have a Teams table with a OneToMany relationship on a Competitors table and also on the Events table.
In a minimalist test with all the entities generated by make:crud, the operation is satisfactory.
In the presentation, I want the home page to list the Competitions (with their Type) and a Registration button for each.
I load the competition selection in the session; I don't want it to appear again in the registration form.
I retrieve the competition Id from the session in TeamsController and I initiate the Competition field in Teams using setCompetition($id) before calling the form (which therefore doesn't include this input field).
After validation, when I try to save to the database $em -> flush(), I get the error "Unable to find ID of The "Proxies_CG_\App\Entity\TypeCompetition" entity associated with the work unit.
Here's my code for the TeamsController's registration() function.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello
I'm stuck on validating a registration form for a sporting event.
I have an Events table with a ManyToOne relationship on a TypeCompetitions table.
I have a Teams table with a OneToMany relationship on a Competitors table and also on the Events table.
In a minimalist test with all the entities generated by make:crud, the operation is satisfactory.
In the presentation, I want the home page to list the Competitions (with their Type) and a Registration button for each.
I load the competition selection in the session; I don't want it to appear again in the registration form.
I retrieve the competition Id from the session in TeamsController and I initiate the Competition field in Teams using setCompetition($id) before calling the form (which therefore doesn't include this input field).
After validation, when I try to save to the database $em -> flush(), I get the error "Unable to find ID of The "Proxies_CG_\App\Entity\TypeCompetition" entity associated with the work unit.
Here's my code for the TeamsController's registration() function.
`
#[Route(path :'/teams/registration', name: 'app_teams_registration', methods:['GET','POST'])]
public function registration(
Request $request,
EntityManagerInterface $em ,
) : Response{
$session = $request->getSession();
$event = $session->get('event');
// dd($uow);
$em->flush(); // error message on this line
return $this->redirectToRoute('app_teams_index', [], Response::HTTP_SEE_OTHER);
}
`
I called getUnitofWork() but I can't identify why the registration is denied
[TeamsController.php](file:///C:/wamp64/www/test_structure/src/Controller/TeamsController.php#L106) on line 106: [Doctrine\ORM\UnitOfWork](file:///C:/wamp64/www/test_structure/vendor/doctrine/orm/src/UnitOfWork.php#L81) {[#5709 ▼](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref25709) -identityMap: array:3 [▼ "App\Entity\Events" => array:1 [▼ 5 => App\Entity\Events {[#1762 ▼](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref21762) -id: 5 -name: "Vancouvert - Athletics relay race" -typecompetition: Proxies\__CG__\App\Entity\TypeCompetition {[#2358 ▼](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref22358) -id: 5 -type: ? ?string -typecomp: ? Doctrine\Common\Collections\Collection -lazyObjectState: Symfony\Component\VarExporter\Internal\LazyObjectState {#2360 ▶} } -team: Doctrine\ORM\PersistentCollection {[#1619 ▶](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref21619)} } ] "App\Entity\TypeCompetition" => array:1 [▼ 5 => Proxies\__CG__\App\Entity\TypeCompetition {[#2358 ▶](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref22358)} ] "App\Entity\Competitors" => array:2 [▼ 5 => App\Entity\Competitors {[#2292 ▶](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref22292)} 6 => App\Entity\Competitors {[#2308 ▶](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref22308)} ] ] -entityIdentifiers: array:4 [▶] -originalEntityData: array:4 [▶] -entityChangeSets: [] -entityStates: array:6 [▶] -scheduledForSynchronization: [] -entityInsertions: array:2 [▶] -entityUpdates: [] -extraUpdates: [] -entityDeletions: [] -nonCascadedNewDetectedEntities: [] -collectionDeletions: [] -collectionUpdates: [] -visitedCollections: [] -pendingCollectionElementRemovals: [] -persisters: array:1 [▶] -collectionPersisters: [] -evm: Symfony\Bridge\Doctrine\ContainerAwareEventManager {[#4165 ▶](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref24165)} -listenersInvoker: Doctrine\ORM\Event\ListenersInvoker {[#5713 ▶](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref25713)} -identifierFlattener: Doctrine\ORM\Utility\IdentifierFlattener {#5715 ▶} -orphanRemovals: [] -readOnlyObjects: [] -eagerLoadingEntities: [] -eagerLoadingCollections: [] #hasCache: false -hydrationCompleteHandler: Doctrine\ORM\Internal\HydrationCompleteHandler {#5712 ▶} -em: ContainerZ2xqrbl\EntityManagerGhostEbeb667 {[#4010](http://127.0.0.1:8000/teams/teams/registration#sf-dump-1158168740-ref24010) …12}
Beta Was this translation helpful? Give feedback.
All reactions