Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][SF2][Symfony2]SonataAdminBundle, dodanie pola ManyToOne do klasy admina
Crash89
post
Post #1





Grupa: Zarejestrowani
Postów: 191
Pomógł: 7
Dołączył: 3.04.2013

Ostrzeżenie: (0%)
-----


Chciałbym dodać pole product do innego Entity w klasie Admin do SonataAdmin Bundle, ale nie działa to poprawnie.

To jest kod :

  1. class Admin {
  2. protected function configureFormFields(FormMapper $formMapper)
  3. {
  4. $formMapper->with('Rabat', array('class' => 'col-lg-6'))
  5. ->add('name', 'text')
  6. ->add('product', 'entity', [
  7. 'class' => 'AppBundle:Product',
  8. 'property_path' => 'name',
  9. 'multiple' => false,
  10. 'required' => false,
  11. 'empty_data' => null
  12. ])
  13. ->end();
  14. }
  15. }
  16.  
  17. class Rabat {
  18.  
  19. /**
  20.   * @var
  21.   *
  22.   * @ORM\ManyToOne(targetEntity="product", inversedBy="rabats")
  23.   * @ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=true)
  24.   *
  25.   */
  26. protected $product = null;
  27.  
  28.  
  29. }
  30.  
  31.  
  32.  


Problem polega na tym, że gdy dodam pole product jako sonata_type_model to wyświetla tylko label bez select boxa.
A kiedy ustawie te pole na typ entity, to nie mogę tego pola dodać jako null w formularzu admina i kiedy wybiorę jakis product to walidację przechodzi, ale w tabeli rabat pole product_id jest ustawione na null a w polu name jest ustawiane pole name z produktu.
Prosze o pomoc.

Ten post edytował Crash89 9.03.2018, 15:54:44
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 2.10.2025 - 20:28