Код: Выделить всё
neither the property school nor one of the methods school(), getschool()/isschool()/hasschool() or __call() exist and have public access in class Symfony\Component\Form\FormView
Я задавал много других вопросов, подобных этому, но не смог найти подходящего решение.
Вот моя функция контроллера
Код: Выделить всё
public function convertTrialAction(
EventDispatcherInterface $dispatcher,
NetResultsService $netResultsService,
Request $request,
#[MapEntity(mapping: ["groupId"=> "groupId"] )] Organization $organization): Response
{
// default to 1000 student ids
$organization->setMaxStudents(Organization::UNLIMITED_ID_CAP);
$form = $this->createForm(ConvertTrialType::class, $organization);
$form->handleRequest($request);
// dump($form);
$allGood = true;
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->doctrine->getManager();
// update max students
$organization->setMaxStudents($form->get('maxStudents')->getData());
// create or select school
// it's possible we already have a school for this org, in which case the field has been removed from the form
if ($form->has('school')) {
$newOrExistingSchool = $form->get('school')->getData();
if ($newOrExistingSchool['existingSchool'] instanceof School) {
$organization->setSchool($newOrExistingSchool['existingSchool']);
} else {
if ($newOrExistingSchool['newSchool'] instanceof School) {
$school = $newOrExistingSchool['newSchool'];
$em->persist($school);
$organization->setSchool($school);
} else {
$form->get('school')->addError(
new FormError('Either New School or Existing School must be provided')
);
$allGood = false;
}
}
}
$subscriptionData = $form->get('subscriptions')->getData();
foreach ($subscriptionData['applications'] as $app) {
$sub = $organization->getSubscriptionFor($app);
if (!$sub) {
$sub = new OrganizationSubscription();
$sub->setApplication($app)
->setOrganization($organization);
}
$sub->setExpiresOn($subscriptionData['expiresOn'])
->setSubscriptionType($subscriptionData['subscriptionType']);
$em->persist($sub);
}
if ($allGood) {
try {
$em->flush();
// dispatch edit event
$event = new FilterOrganizationEvent($organization);
$dispatcher->dispatch($event, CoreEvents::ORGANIZATION_EDIT);
// now that the trial has been converted, update NetResults
$netResultsService->updateContact($organization->getPrimaryUser()->getEmail(), [
'WBLPurchase' => 'Yes',
'WBLClassification' => $organization->getSchool()->getCategoryLabel(),
'WBLTrial' => 'Converted'
]);
$this->addFlash('success', 'Converted customer from trial');
return $this->redirectToRoute('admin_organization_view', ['groupId' => $organization->getGroupId()]);
} catch (Exception $e) {
$form->addError(new FormError($e->getMessage()));
}
}
}
return $this->render('Admin/Organizations/convertTrial.html.twig', [
'form' => $form->createView(),
'organization' => $organization,
'isTrial' => $organization->isTrialCustomer()
]);
}
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/79354262/neither-the-property-school-nor-one-of-the-methods-school-getschool-exi[/url]