Guest User

Untitled

a guest
Nov 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. $builder->add('contactPerson', EntityType::class, [
  2. 'class' => 'AppBundle:User',
  3. 'choice_label' => 'username',
  4. 'empty_data' => null,
  5. 'required' => false,
  6. // 'placeholder' => '' - Can be ommited, empty value is default
  7. ]);
  8.  
  9. manyToOne:
  10. contactPerson:
  11. targetEntity: AppBundleEntityUser
  12. joinColumn:
  13. name: contact_person
  14. referencedColumnName: id
  15. onDelete: RESTRICT
  16. nullable: true
  17. fetch: EAGER
  18.  
  19. public function editAction(Request $request, $id)
  20. {
  21. /** @var CountryService $countryService */
  22. $countryService = $this->get('app.country');
  23. /** @var Country $country */
  24. $country = $countryService->findById($id);
  25.  
  26. if (!$country) {
  27. $this->addFlash('error', 'back.country.not_found');
  28. return $this->redirectToRoute('back_country_list');
  29. }
  30.  
  31. $form = $this->createForm(
  32. CountryType::class,
  33. $country,
  34. [
  35. 'edit_action' => true
  36. ]
  37. );
  38. $form->handleRequest($request);
  39.  
  40. if ($form->isValid()) {
  41. $countryService->edit($country);
  42.  
  43. $this->addFlash('success', 'back.country.edited');
  44. return $this->redirectToRoute('back_country_edit', ['id' => $id]);
  45. }
  46.  
  47. return $this->render(
  48. 'AppBundle:backcountry:edit.html.twig',
  49. [
  50. 'form' => $form->createView()
  51. ]
  52. );
  53. }
  54.  
  55. "contactPerson" => ""
Add Comment
Please, Sign In to add comment