Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][SF2][Symfony2] buildForm problem, Object of class could not be converted to string
damianooo
post 19.06.2017, 20:47:06
Post #1





Grupa: Zarejestrowani
Postów: 496
Pomógł: 2
Dołączył: 15.07.2011
Skąd: Katowice

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


Połączyłem encję MEET (mecz) z nową encją LEAGUE (liga) i w CRUD dla funkcji CREATE muszę teraz dodać w formularzu nowe pole w którym będę mógł wybrać rodzaj ligi dla meczu.

Po dodaniu w klasie MeetType nowego pola dostaję jednak komunikat z poniższym błędem.
Nie do końca rozumiem komunikat tzn. w którym miejscu klasa nie może być konwertowana do typu String ?
  1. Catchable Fatal Error: Object of class AppBundle\Entity\League could not be converted to string


Klasa formularza - MeetType.php :

  1. class MeetType extends AbstractType
  2. {
  3. /**
  4.   * {@inheritdoc}
  5.   */
  6. public function buildForm(FormBuilderInterface $builder, array $options)
  7. {
  8. $builder->add('name')
  9. ->add('matchday')
  10. ->add('league')


klasa entity MEET - Meet.php :
  1. /**
  2.   * @ORM\ManyToOne(
  3.   * targetEntity = "League",
  4.   * )
  5.   *
  6.   * @ORM\JoinColumn(
  7.   * name = "league_id",
  8.   * referencedColumnName = "id",
  9.   * onDelete = "SET NULL"
  10.   * )
  11.   */
  12. private $league;


próbowałem też tak:

  1. ->add('league', 'collection', array(
  2. 'type' => new League(),
  3. 'allow_add' => true,
  4. 'allow_delete' => true,
  5. 'by_reference' => false,)
  6. )


ale wtedy dostaję podobny komunikat:

  1. Expected argument of type "string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface", "AppBundle\Entity\League" given


Ten post edytował damianooo 19.06.2017, 20:47:41
Go to the top of the page
+Quote Post

Posty w temacie


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: 10.07.2025 - 05:39