Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][Symfony4][SF4] EnumType in Form field
damianooo
post 23.10.2022, 22:15:10
Post #1





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

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


Stworzyłem sobie typ Enum z wartościami:

  1. <?php
  2.  
  3. namespace App\Form\Enum;
  4.  
  5. enum MeetName: string {
  6. case MECZ1 = 'Mecz 1';
  7. case MECZ2 = 'Mecz 2';
  8. }


dodałem go sobie do formularza :

  1. <?php
  2. namespace App\Form;
  3.  
  4. use Symfony\Component\Form\Extension\Core\Type\EnumType;
  5. use App\Form\Enum\MeetName;
  6.  
  7. class MeetType extends AbstractType
  8. {
  9. public function buildForm(FormBuilderInterface $builder, array $options)
  10. {
  11. $builder
  12. ->add('name' , null, ['label' => 'Nazwa'])
  13. ->add('name' , EnumType::class, [
  14. 'class' => MeetName::class
  15. ])


i wydawało mi się że dobrze dodałem , zgodnie z dok.:
https://symfony.com/doc/current/reference/f...types/enum.html

ale niestety mam taki błąd:

Expected to find class "App\Form\Enum\MeetName" in file "C:\xampp\htdocs\ligatyperow2\src/Form\Enum\MeetName.php" while importing services from resource "../src/*", but it was not found! Check the namespace prefix used with the resource in C:\xampp\htdocs\ligatyperow2\config/services.yaml (which is loaded in resource "C:\xampp\htdocs\ligatyperow2\config/services.yaml").

co mam nie tak ?
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: 26.05.2024 - 21:57