Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SF][Symfony2][Symfony] Data Transformer problem
aras785
post 8.07.2015, 11:20:42
Post #1





Grupa: Zarejestrowani
Postów: 859
Pomógł: 177
Dołączył: 29.10.2009

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


Cześć.

Zainstalowałem: https://github.com/PUGX/PUGXAutoCompleterBu...es/doc/index.md (select2). Troche musiałem zmienić w js ale formularz działa poprawnie (znaczy się pole wyszukuje poprawnie).

Ale niestety gdy chcę zapisać pole to dostaję błąd:


w kontrolerze daję:
  1. $form = $this->createFormBuilder($company)
  2. ->add('email','text',array('label'=>'Email'))
  3. ->add('name','text',array('label'=>'Nazwa'))
  4. ->add('street','text',array('label'=>'Ulica'))
  5. ->add('id_city','autocomplete',array('label'=>'Miasto','class'=>'Acme\Bundle\AdminBundle\Entity\City'))
  6. ->add('state','choice',array('label'=>'Województwo','choices'=>array('Dolnośląskie','Opolskie')))
  7. ->add('zipcode','text',array('label'=>'Kod pocztowy'))
  8. ->add('phone','text',array('label'=>'Telefon'))
  9. ->add('nip','text',array('label'=>'NIP'))
  10. ->add('website','text',array('label'=>'Website'))
  11. ->add('save', 'submit', array('label' => 'Zapisz'))
  12. ->getForm();

Entity dla company:
  1. ...
  2. /**
  3.   * Set idCity
  4.   *
  5.   * @param \Acme\Bundle\AdminBundle\Entity\City $idCity
  6.   * @return Company
  7.   */
  8. public function setIdCity(\Acme\Bundle\AdminBundle\Entity\City $idCity = null)
  9. {
  10. $this->idCity = $idCity;
  11.  
  12. return $this;
  13. }
  14.  
  15. /**
  16.   * Get idCity
  17.   *
  18.   * @return \Acme\Bundle\AdminBundle\Entity\City
  19.   */
  20. public function getIdCity()
  21. {
  22. return $this->idCity;
  23. }

Entity City wygląda stand. ID | Name itd.

A tutaj transfermer i formularz typu: autocomplete:
https://github.com/PUGX/PUGXAutoCompleterBu...ree/master/Form

Dziękuje.

pozdrawiam
Go to the top of the page
+Quote Post
ohm
post 8.07.2015, 11:38:25
Post #2





Grupa: Zarejestrowani
Postów: 623
Pomógł: 144
Dołączył: 22.12.2010

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


A debugowałeś chociaż co przechodzi (i czy w ogóle coś przechodzi) przez ten transformer?
Go to the top of the page
+Quote Post
aras785
post 8.07.2015, 11:49:13
Post #3





Grupa: Zarejestrowani
Postów: 859
Pomógł: 177
Dołączył: 29.10.2009

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


Cytat(ohm @ 8.07.2015, 12:38:25 ) *
A debugowałeś chociaż co przechodzi (i czy w ogóle coś przechodzi) przez ten transformer?


Nie wiem czy dobrze rozumiem. W Klasie ObjectToIdTransformer:
- metoda: transform zwraca "id" dobrze
- metoda reverseTransform - jakby wgl się nie uruchamiało...
Go to the top of the page
+Quote Post
ohm
post 8.07.2015, 12:09:30
Post #4





Grupa: Zarejestrowani
Postów: 623
Pomógł: 144
Dołączył: 22.12.2010

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


Spróbuj ten transformer podpiąć pod główny formularz
  1. ->add($builder->create('id_city','autocomplete',array('label'=>'Miasto','class'=>'Acme\Bundle\AdminBundle\Entity\City'))->addModelTransformer($transformer))


Ten post edytował ohm 8.07.2015, 12:12:50
Go to the top of the page
+Quote Post
aras785
post 8.07.2015, 12:38:02
Post #5





Grupa: Zarejestrowani
Postów: 859
Pomógł: 177
Dołączył: 29.10.2009

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


Zaraz to sprawdzę ale według mnie to ten cały bundl traci sens...

Ten post edytował aras785 8.07.2015, 12:38:16
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 7.07.2025 - 20:49